Solved

Coldfusion regexp question (kaufmed) - revisited

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 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