Gecko comes first in the string that is being searched. When the regex engine is trying to match a regex in a string, it starts at the first character of the string and tries to match from the beginning of the regex. If it can't match at that position, it moves to the next character of the string and starts trying to match again (unless you anchor the regex). In this case, the match keeps failing until it gets to the point in the string where 'Gecko' appears. At that point, the regex engine says to itself: "Can this match 'opera'? No. Can this match 'netscape'? No. Can this match 'gecko'? Yes. Return captured string 'gecko'. Done." Which happens before it gets to the point in the string where 'Netscape' appears.
kelan
Perl6 Grammar Student
| [reply] |
Thanks for clearing that up!
So...
It takes the first word of the string ("Mozilla" in this case) and compares it to each regex, opera then netscape then gecko ...
This is reversed as to how I interprited it. I guess I think about it backwards, as taking opera and comparing that to each word in the string.
| [reply] |
| [reply] |
left right
| |
Gecko/20011019 Netscape6/6.2
| [reply] [d/l] |