Solved

Coldfusion regexp question (kaufmed) - revisited

Posted on 2011-09-02
5
320 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
  • 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now