Reputation: 11790
If I have 1) /foo|oo/
2) /oo|foo/
and using PCRE and I match it against the string "foo" the expected result is
foo
2) oo
. PCRE keeps "OR" order.foo
. PCRE tries all variants and goes for longest match."Try it and see" seems to kill 1.) but there is no way to determine between 2-3-4 just by trial and error.
Upvotes: 2
Views: 3888
Reputation: 198476
4) Get the match closest to the start of the string. When multiple matches are possible from the current position, match the option that matches sooner.
e.g.
banana
matching against /na/
(showing the match with uppercase): baNAna
(sooner than banaNA
). Against /an|b/
, matches Banana
(sooner than bANana
). Against /ba|./
, matches BAnana
(same position, so ba
matches before .
). Against /.|ba/
, matches Banana
(same position, so .
matches before ba
).
Upvotes: 2