This is regarding regex backreference.
I'm not sure you're using the right terminology, but here's an example in which a regex with a backreference is entered, matches and captures:
>perl -wMstrict -le "$_ = '1:A silly sentence (495,a), silly but useful.(3)'; ;; print 'Enter a regular expression:'; my $expression = <STDIN>; chomp($expression); print qq{expression is '$expression'}; ;; if (/$expression/) { print 'The expression matches the string'; print qq{\$1 is '$1'} if defined $1; print qq{\$2 is '$2'} if defined $2; print qq{\$3 is '$3'} if defined $3; } else { print 'The expression does not match'; } " Enter a regular expression: (\w+).*(\1) expression is '(\w+).*(\1)' The expression matches the string $1 is 'silly' $2 is 'silly'
See discussion of backreferences in Capture groups in perlre.
In reply to Re: Regex backreference
by AnomalousMonk
in thread Regex backreference
by vyeddula
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |