in reply to Search and replace logic

s/(n(?i:s|c)e)/$1 ^ "nse" ^ "nce"/gie;

Of course, that's only if you want to keep its case (mad props to Abigail-II for the nifty trick :-). However, if you want a more general mechanism for mapping particular words to other words and don't mind about the case:

my %word_map = ( nce => "nse", nse => "nce" ); my $re = join "|", map qr/\Q$_/i, keys %word_map; s/($re)/$word_map{lc $1}/ge; print

That would be a more general mechanism even though it doesn't keep case.

Hope this helps.