In 5.10+, see also named capture buffers:
>perl -wMstrict -le "my $str = 'The CEO of WidgeCo resigned today.'; ;; $str =~ m{ (?<BIGWIG> chairman | president | ceo ) }xmsi; ;; if (exists $+{BIGWIG}) { print qq{a $+{BIGWIG} was mentioned}; } " a CEO was mentioned
Update: For the position in the string of the match(es), see @- and @+ in perlvar.
In reply to Re: What is being matched?
by AnomalousMonk
in thread What is being matched?
by eversuhoshin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |