Minor adjustment:
$line =~ / ^ (.+?) (?: < (two|three) > )? $ /xs;
Another approach:
my $pre= $line; my $post= ''; if( $pre =~ s/ \s* < (two|three) > $ //xs ) { $post= $1; }
- tye
In reply to Re: Regex: Optional/alternative catpures (two)
by tye
in thread Regex: Optional/alternative catpures
by wfsp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |