2 ms·
> Yep, basically this, but with a super ugly regex And where, if you don't mind me asking, have you ever seen a pretty regex? > why learn something useful lik
by klibertp 10y ago
> Yep, basically this, but with a super ugly regex
And where, if you don't mind me asking, have you ever seen a pretty regex?
> why learn something useful like regular expressions, when you can use some custom library with 1/10th the power!
Regular expressions are not that powerful anyway, but they compensate this by being highly unreadable and error-prone.
In very many cases you don't need 90% of the power of regexes - you just want to extract a certain portion of a string, without worrying about greediness, character classes, double-triple-quadruple quotation with backslashes and so on. Which is where `parse` shines.
And if you see that simpler tool like `parse` is not enough, my advice is to jump over regexes and go straight for `pyparsing`. Regexes are a mess, no matter how careful you are when constructing them. A proper parser is going to be a better choice every single time.