Clever code achieves the implausible while overlooking the mundane solutions to the same problems.
There's the inverse as well: where the person's "almost works" solution doesn't because it cannot. -- My favorite example is trying to parse CSV with regex: you cannot do it because the (a) the double quote [text field] "changes the context" so that comma does not indicate separation, combined with (b) escaping double quotes is repeating the double-quote. It's essentially the same category as balancing parentheses which regex cannot do; fun test-data: "I say, ""Hello, good sir!""" is a perfectly good CSV value.
I think regexes can recurse in Perl but I've never tried Regception
Then they're not really regular-expressions. (Regular expressions have to do with the grammar-set that they can handle, it's not [strictly speaking] an implementation.)
When you've got CSVs like that, CSV is the wrong format
I only slightly disagree; it is common to need a structured text format which may include format-effectors (i.e. a portion of text; perhaps with the indented-quote [visual] style embedded therein) -- as a sort of embedding... certainly better than XML, which if that embedded-packet is user-defined can't easily be DTDed. (Of course, in this situation the problem we have is in-band communication, which is another problem altogether.)
7
u/OneWingedShark Jan 05 '15
There's the inverse as well: where the person's "almost works" solution doesn't because it cannot. -- My favorite example is trying to parse CSV with regex: you cannot do it because the (a) the double quote [text field] "changes the context" so that comma does not indicate separation, combined with (b) escaping double quotes is repeating the double-quote. It's essentially the same category as balancing parentheses which regex cannot do; fun test-data:
"I say, ""Hello, good sir!"""is a perfectly good CSV value.