Backreferencing and greedy quantifiers : Index « Regular Expression « Perl






Backreferencing and greedy quantifiers

    

$string="asdfadfadfadsfasdf YOU!";
$string=~s/(.*C)(.*)/HEY/; # Substitute the whole string with HEY
print $1, "\n";
print $2, "\n";
print "$string\n";

   
    
    
    
  








Related examples in the same category

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