August 23rd, 2013, 01:15 PM
Regex to get string after last backslash (\).
I have a file that I need to extract the string after the last backslash. Basically, the strings to find are:
I would like some assitance to build the regular expression so I can get the last word after the last \ of each line.
Thanks in advanced,
August 23rd, 2013, 01:28 PM
Non-slash stuff with an end-of-line anchor.
August 23rd, 2013, 01:37 PM
Originally Posted by requinix
Thanks for reply. Bu I don't know how to get started. Would you mind if you write the regex for me? The final result would be:
August 23rd, 2013, 01:56 PM
1. Use a negated character set [^...] and inside put a slash. Thus "everything but a slash".
2. Repeat that character set using * or + (probably the latter).
3. After it comes and end-of-line anchor $.
August 23rd, 2013, 02:22 PM
I tried the following regex: [^workingDirectory=c:\\web\\intra\\Forms\\*]$
but didn't work. What am I missing?
August 23rd, 2013, 04:40 PM
You could try:
(one backslash, followed by one or more non back-slashes, followed by optional spaces, followed by end of line.
Or, yet simpler:
one or more word characters (i.e. A-Z, a-z, 0-9 and _), followed by optional spaces, followed by end of line.