in reply to Re^4: out of two strings which occurs first in a text
in thread out of two strings which occurs first in a text
If you wanted to get the longest first, sort the elements of the alternation.
my ($re) = map qr/$_/, join '|', map quotemeta, sort { length($b) <=> length($a) } @words;
Of course, that doesn't work for patterns that can match strings of various lengths.
|
|---|