I think one of the problems is the greedy .+ at the start of the regex. It would be better to leave it off or make it nongreedy. Then, just sorting by length decreasing makes the thing work again:
>perl -wMstrict -lE "say /^.+?(s m e f|s f pl|s f).+$/ for '-s m e f s + f pl s f-';" s m e f
In reply to Re^2: match longest sequence in an "or" RE
by Corion
in thread match longest sequence in an "or" RE
by silentius
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |