Matched index : Index « Regular Expression « Perl






Matched index

    

#!/usr/bin/perl
use warnings;
use strict;

my $text= "Testing";
if ($text =~ /((?:T|N)est(ing|er))/) {
    print " \$1 = $1 \n \$2 = $2 \n \$3 = $3 \n \$4 = $4 \n";
}

   
    
    
    
  








Related examples in the same category

1.Back referencing
2.Backreferencing and greed
3.Backreferencing and greedy quantifiers
4.Match the first alphanumeric character
5.$1 gets 'A', $2 gets' B'
6.Regex index