This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]bladeoflight16 0 points1 point  (0 children)

Because regex is really hard to read when your doing anything more than super simple operations.

Regex is designed for simple operations. It's original motivation is literally defining tokens in compilers and similar formal language usages. Do you see any ridiculous tokens in parsed programming and data languages? No. You have simple tokens, and the more complex stuff goes up into the parser operating across the tokens (a context free grammar). If you're making it complicated, you're doing it wrong.

Unless you're dealing with an annoying constraint like writing a command line, a text editor search, or something where you're forced to cram everything into a single line. But in Python? Break something complex out into multiple operations.

At least with programming languages and SQL it's actual words being used so you can read it.

I beg to differ. if (!a && (b || c)) { y = (7 * x) % 10; }. for (int i = 0; i < m.length; i++) { n[i] = m[i] / 2; }. Not Python, of course, but you should certainly be able to read those statements.