my %repl = ( find => 'repl', FIND => 'REPL', Find => 'Repl', ); s/\b(find)\b/$repl{$1}||$repl{lc $1}/gie