Solved

Coldfusion regexp question (kaufmed) - revisited

Posted on 2011-09-02
5
323 Views
Last Modified: 2012-06-27
Hi,

Kaufmed provided me with a neat lil regexp to strip out extra spaces after the 1st and 2nd token. But I did not award him the max points, my mistake! His regexp was the correct requirement. However, I now have an additional piece that I need added. My test string:

dt - tl  -  dist track & sprint - high & middle - 327 -  indoor meet

Kaufmed's regexp now removes the whitespaces after the first t, after the 1st hyphen, after the 1st l and after the 2nd hypen. I need to be able to remove the whitespace after the last hyphen as well. How do I do this? (this way I can also make sure kaufmed gets the full points :)  )
0
Comment
Question by:roger_v
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 35

Assisted Solution

by:Terry Woods
Terry Woods earned 200 total points
ID: 36477031
Building on kaufmed's code, this should work I think:

REReplace(field, "^([^ -]+) *- *([^ -]+) *(.*-) *", "\1-\2\3")
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 36477221
By the way, if you want kaufmed to get full points from the previous question, I think you can use the "Request Attention" link to reopen the question and reassign points - you may need to state your justification for it though.
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 300 total points
ID: 36479199
Now is my longer <|:-)
<cfset myStr=ReReplace(myStr, "^([^ -]+) *- *([^ -]+) *- *([^ -]+) *(.*-) *", "\1-\2-\3\4") >

Open in new window

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 36479211
Sorry, it can be shorter:
<cfset myStr=ReReplace(myStr, "^([^ -]+) *- *([^ -]+) *- *(.*-) *", "\1-\2-\3") >

Open in new window

0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question