Difference between the behaviour of awk and perl in regex alternation

Viewed 54

Look into this:

$ echo sixty | awk '{ sub(/six|sixty/, "X"); print }'
X
$ echo sixty | perl -pe 's/six|sixty/X/'
Xty

perl stops at the first match and awk continues to search for a "better" match. sed and grep behave same as awk. Why does the behaviour of awk/sed/grep and perl differ in regular expression alternation, and is this difference documented anywhere?

0 Answers
Related