I am sure this must have been asked before, but for some reason finding answers in the archive to problems with regular expressions is particularly difficult for me.
I would like to do a lookbehind starting at the end of a string.
Example string:
"This is a string with lots of white space_and-other.stuff"
I only want the part of the string that has the very last whitespace in front of it. So far I have the following:
(?<=\s).+$
which gives me everything after the first whitespace, even though I am matching against the end of the string. I the root of my problems must have something to do with lookbehinds having to be a predefined number of characters, but I don't know how to do it without a lookbehind.
Why do you need lookbehind. You can get it using this regex: