![]() |
|
Do you know where your variables are? | |
PerlMonks |
Re^3: brackets matching problemby Dietz (Curate) |
on Aug 19, 2004 at 09:11 UTC ( [id://384219]=note: print w/replies, xml ) | Need Help?? |
Out of perldoc perlre: Alternatives are tried from left to right, so the first alternative found for which the entire expression matches, is the one that is chosen. This means that alternatives are not necessarily greedy. For example: when matching "foo|foot" against "barefoot", only the "foo" part will match, as that is the first alternative tried, and it successfully matches the target string. (This might not seem important, but it is important when you are capturing matched text using parentheses.) Let's look at a simply modified test sample: will match 1 because 3 ist optional and will match 12 because it has to satisfy the entire expression and so it will match 3 at the end of the string Add: For clarifying, the first example will have '1' in $1 and nothing in $2 Second example will have '12' in $1 and '3' in $2
In Section
Seekers of Perl Wisdom
|
|