Ah, that would be when you check to see whether $2 is defined or not. You get $2 just because it is written into the source of the expression, not because it matched. Its value will be the value undef if the expression matches and that portion of the expression was not used. So for the expression /(\d{1,4}) (?:\t (.{1,40}) )?/x the tab with following stuff is optional and then you just look at the parts that interest you.
In reply to Re: Re: regexp
by diotalevi
in thread optional regexp parts?
by matth
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |