I am trying to match only the phrase that is positioned at the end of the sentence, just after a comma. I could split the string by commas and grab the last index but how can I do the same with regex that finds 1 or more words going form right to left and ends at first comma?
string str = "some string, number 555 more strings, final string";
var match = new Regex(@"(?=,\s).*", RegexOptions.RightToLeft).Match(str).Value;
Console.WriteLine(match); // , number 555 more strings, final string
In snippet above I tried to match final string
only.
If regex101 had the right-to-left feature I would tinker with it as usually until I found the proper syntax.
I tried to use both lookahead and lookbehind but I find it very confusing when going right to left.