On 06/01/2016 12:33 PM, Марк Коренберг wrote:
Example:
$ echo qwerty | egrep -o 'we|wert'
wert
$ echo qwerty | egrep -o 'wert|we'
wert
That's not a bug; it's a feature. See, for example:
https://swtch.com/~rsc/regexp/regexp1.html
Example:
$ echo qwerty | egrep -o 'we|wert'
wert
$ echo qwerty | egrep -o 'wert|we'
wert
The same in Javascript:
/we|wert/.exec('qwerty')
["we"]
/wert|we/.exec('qwerty')
["wert"]
http://stackoverflow.com/questions/2394931/regex-is-behaving-lazy-should-be-greedy
$ egrep --version
grep (GNU grep