Mega Code Archive

 
Categories / Perl / Regular Expression
 

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";