I have a string "Foo Bar Foo Bar", I want to select the first Bar in that string
At the moment I have: http://regexr.com?37mv1 which is not quite right
This is the first Foo 'Bar' I ever had in Foo Bar. 'Bar' should be picked up.....Hope it makes sense
you can use this:
or more simple:
or more efficient (with long strings):
The problem of your pattern is the first greedy quantifier
.*. This subpattern will match all possible character until the end of the string/line, then the regex engine must go back character by character until it findFoo, but theFooit find is the last.A lazy quantifier
.*?will check for each characters ifFoofollows.Note: you can uncheck the
iandgcheckboxes in gskinner.