Let\'s say I have string \"The quick brown fox jumps over the lazy dog\" can I change this to \"The slow brown fox jumps over the energetic dog\" with one regular expression
Chas's answer is good, the only other thing I'd mention is that if you're doing word swaps you probably want to be matching on
\b(foo|bar|baz|qux)\b
to avoid matching substrings. If you doing a lot of word swapping, you might start to find regexps a bit limiting and want to do something like:
join '', map { exists $subst{$_} ? $subst{$_} : $_ } split /\b/, $string