I have a string and I need to parse it for a value…
var msg = "Sometext can't do this. Blah blah blah Version id: 'xxx'";
How can I use regex and get the text between the last two single quotes? xxx
Notice the first single quote in {can’t}
The value I’m seeking will always be between the last set on single quotes.
A brief explanation of the regex would be awesome as well.
Thanks so much for any help, tips, examples.
This is the final Regex
The general pattern I use is
It finds a pattern that lies between a prefix and a suffix. What we want to find is
This means anything but the single quote (
') repeated zero or more times.Finally we look for
'$at the end, not just'. This means that the single quote must be at the end of the line.