in reply to brackets matching problem
What do you find odd?. With alternation | Perl will match the first element if it can, if not the next ... so in the first case it finds a 1 which satisfies the first capture and then the second capture takes the optional 2. In the second case you get 12 as the first capture and then the second captuere 2? 'matches' the 3 as 3 is 0 or more 2s..... (actually it matches the null string between 2 and 3 to be technically correct.
cheers
tachyon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: brackets matching problem
by lucky8 (Initiate) on Aug 19, 2004 at 08:45 UTC | |
by Dietz (Curate) on Aug 19, 2004 at 09:11 UTC | |
by lucky8 (Initiate) on Aug 19, 2004 at 10:07 UTC | |
by hanenkamp (Pilgrim) on Aug 19, 2004 at 11:56 UTC |