in reply to Re: Finding out which of a list of patterns matched
in thread Finding out which of a list of patterns matched

Are you sure of that? I'm only fairly new to Perl so I could be interpreting this wrongly, but in the Camel book (which I've been reading) it says:

"...But the ordering of the alternatives only matters at a given position. The outer loop of the Engine does left-to-right matching, so the following always matches the first Sam:"
"'Sam I am,' said Samwise" =~ /(Samwise|Sam)/; # $1 eq "Sam"
which suggests to me that the match earliest in the text will be found. If that isn't the case it's going to make my life a whole lot more difficult...:P

Replies are listed 'Best First'.
Re^3: Finding out which of a list of patterns matched
by duff (Parson) on Jan 23, 2006 at 15:29 UTC

    Ho, ho, you are right! I don't know what I was thinking.