I have a list of pairs like (regex, substitute) that take quite long to apply to some input text so I was thinking about optimizing them a bit.
From my knowledge for each regular expression there is a deterministic finite automaton that accepts the same language, and as its possible to merge DFAs merging two regex should be possible...
My question is now how does this interact with the fact that I want to replace something and not just match it.
Basically: given two pairs of a regex and its replacement in a specific order:
1. /\./ -> "Found #DOT#"
2. /#DOT#/ -> "something"
Is it programmatically possible to create a new pair:
/\./ -> "Found something"
that applied to some input creates the same result?
Note: are e.g. Python regex even regular in the sense of theoretical informatic? (I mean would I get problems with e.g. look-arounds?)
My reason for asking: there are some regex-chains in my collection that just replace things with other things so that other regex can replace these things but that's only to keep it simple enough for a human to understand, a computer doesn't need to comprehend the regex.