Is string matching and replacement considered in formal languages?
Match &amp; replace is a special case of rational transduction, a quite powerful class of string mappings with a number of nice properties.

The classes of regular, context-free and recursive enumerable languages are all closed against rational transduction (source), so this carries over to match &amp; replace.

It does not seem as if the necessary elementary operations had a representation in formal language theory.