Finite-State Transducers for Text Rewriting
Text rewriting is a programming task when parts of a given input string are replaced with other strings. Applications of this process include text highlighting, annotation, lexical analysis, normalization, etc. Because such tasks arise quite often in practice, many programming languages provide built-in text rewriting APIs. Those APIs, however, often go beyond the realm of regular languages, but rewriters based on regular expressions are still very powerful and can to solve most of the translation tasks that occur in practice. In this article, we'll describe the process of text rewriting from a set-theoretic perspective and define the relevant formalisms. We'll see how they can be applied to implement powerful text rewrites that replace the matching parts of the input string in a single scan.
Denis Kyashif's Blog