2 ms·
This is something that always makes me sad: In C, the escape character for literal strings, as interpreted by the C compiler, is the backslash. ("\") Also in
by thaumasiotes 3y ago
This is something that always makes me sad:
In C, the escape character for literal strings, as interpreted by the C compiler, is the backslash. ("\")
Also in C, the escape character for format strings, as interpreted by the printf function, is the percentage sign. ("%")
This is the correct way to do things, for the very obvious reason that neither the compiler nor printf can get confused by the input the programmer provides. Directions to the compiler look nothing like directions to printf.
But for some reason, this knowledge of how to define formats was completely forgotten, and so regular expression parsers were all defined to use a backslash as their escape character. There is no earthly reason you would want to do this. It causes many, many problems, and has no benefits, to use the same escape character for the compiler/interpreter and for the regex engine. But we're doing it anyway.
- vbezhenar 3y agoLua uses % for patterns.