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
In reply to Re: brackets matching problem
by tachyon
in thread brackets matching problem
by lucky8
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |