Solved

Coldfusion regexp question (kaufmed) - revisited

Posted on 2011-09-02
5
319 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
Comment Utility
Building on kaufmed's code, this should work I think:

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

Expert Comment

by:Terry Woods
Comment Utility
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
Comment Utility
Now is my longer <|:-)
<cfset myStr=ReReplace(myStr, "^([^ -]+) *- *([^ -]+) *- *([^ -]+) *(.*-) *", "\1-\2-\3\4") >

Open in new window

0
 
LVL 63

Expert Comment

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

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

15 Experts available now in Live!

Get 1:1 Help Now