-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Hello,
I am using re2 in conjunction with Google BigQuery and am experiencing unexpected match order results from a regular expression operation.
Here is the regular expression I am using: .*(?i)(foo|bar).*
I am applying this regular expression to the following strings:
String 1: "foo bar"
String 2: "bar foo"
My understanding of regular expressions leads me to expect "foo" to be the first match in both cases, as it precedes "bar" in both the regular expression and the test strings.
However, the actual results I'm seeing are:
For String 1 ("foo bar"), the match is "bar"
For String 2 ("bar foo"), the match is "foo"
I am trying to understand why the match order appears to be reversed from what I expect. Does re2 handle regular expression matching differently than other engines? Is there a way I can modify the regular expression or use a different function to achieve the expected order?
Thank you in advance for any insights you can provide.