If I have 1) /foo|oo/
2) /oo|foo/
and using PCRE and I match it against the string "foo" the expected result is
- 1)
foo
2)oo
. PCRE keeps "OR" order. foo
. PCRE tries all variants and goes for longest match.- There is no preset rule, the optimizer might reorder as it sees fit. It is the duty of the developer to avoid ambiguous scenarios like this.
- There is a rule but it's not 2.
"Try it and see" seems to kill 1.) but there is no way to determine between 2-3-4 just by trial and error.