3 ms·
There is a third point that trumps these two: having a structured format allows you to programmatically compose regular expressions. In most string encoding it
by afiori 4y ago
There is a third point that trumps these two: having a structured format allows you to programmatically compose regular expressions.
In most string encoding it is hard or unergonomic to safely embed regexes or string literals in other regexes.
In this sense a regex is quite similar to SQL, just used for simpler operations generally.
It is to be noted that while regexes are used to parse (mostly) regular languages, the language of regex expressions is fully context-free.
Personally I dislike manually embedding context-free languages inside a regular encoding (strings) already embedded inside another context free language that could have just added support for structured regexes in the first place.