Mega Code Archive
Categories
/
Perl
/
Regular Expression
$1 gets A, $2 gets B
$str = "A and B"; $str =~ s/(A) and (B)/$2, $1/i; print $str;