Alternately:
Main Topics
Browse All TopicsZum Alles,
Given the string:
"xxxxx x xxxxxxxxxx","nnnn xxxxxxxxxxxxxxx","xxxxxxx xx nnnnn/lf
I want to find and replace the last occurence of ' ' in the line of text with a ", to give me the following:
"xxxxx x xxxxxxxxxx","nnnn xxxxxxxxxxxxxxx","xxxxxxx xx "nnnnn/lf
This REGEX " ^*\s " finds the first space in line. I can not figure out a REGEX to find the last space in the line.
Any help would be appreciated.
Thanks
Mike
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
To all: For learning/instructional/tes
I need to simply my initial problem request to two parts.
First part of question, and most significant part.
1)Find last space in line of text.
2)Replace that single space with a single "
Thanks
Mike
The replacement string is just a single double quote character.
As for \Z or \z, they serve similar functions to the $ token. Which one you use really depends on your data and what your regex modifiers are. In most cases (simple, single-line strings with an optional carriage return at the end and no embedded carriage returns in the middle), the $ is used and does what you are looking for. Regex Coach is great for helping you see what happens if your Target string contains multiple lines, what happens if the "m" or "s" regex modifiers are turned on, etc.
One thing you might also want to try (if you haven't already) is the Step functionality in Regex Coach that allows you to see exactly how the computer "executes" your regular expressions. It can be eye-opening at times to see how efficient or inefficient some regular expressions can be. It also can help you build a regular expression if you can see where the one you were working on strays from the behavior you are after.
Business Accounts
Answer for Membership
by: bounsyPosted on 2009-07-02 at 10:45:22ID: 24765756
In Perl regex:
Select allOpen in new window