3 ms·
> Matching string literals is kind of gross, Only because the escape sequence for a quote is \" instead of, say, \q. Then it'd have been a very straightforward
by Joker_vD 2y ago
> Matching string literals is kind of gross,
Only because the escape sequence for a quote is \" instead of, say, \q. Then it'd have been a very straightforward regex "[^"]*" to match a string literal. On a slightly related note, having the escape sequence for a backslash to be \z or something like that instead of \\ mitigates the "leaning toothpick syndrome" quite a lot. Both of these choices are unpopular for no particular reason IMHO other than "it's different from what all the C-like languages do".
- im3w1l 2y agoI think that for matching this should work ([^"\\]|\\.)* If you want to validate and interpret the backslash escapes then it's a little more work especially if you accept \uXXXX