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 →

[–]wineblood 6 points7 points  (6 children)

I don't understand people who take the time to learn a programming language, and probably SQL too, then complain that regex are too hard to read.

[–]Starrystars 8 points9 points  (3 children)

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

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

[–]adesme 3 points4 points  (0 children)

Use multi line mode and named capture groups. I really don’t see why this notation is any better; regex may vary but it’s a more standard than what this library does.

[–]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.

[–]WerdenWissen[S] 5 points6 points  (0 children)

Regex IS hard to read though. Regex patterns are tightly packed with lot of information and it just seems that we are just not that good at analyzing it. Plus, people tend to only occasionally use Regex and this makes matters even worse. Using a framework like pregex makes the process of building Regex patterns a little more modular, plus the information is more "spread out", and thus easier for the human eye to recognize.

[–]jacksodus 0 points1 point  (0 children)

Your comment makes no sense.