I've never really had problems with regex, but I think that's because I treat them as a simple tool. I've seen people get in trouble trying to create pretend grammars or embed application logic in regex and that can range from headache to mathematical impossibility. Thinking of them as the arithmetic of strings clarifies most situations. If you are the kind of person that takes a float and runs it through a couple of pages of algebra to make web pages then someone needs to take you in hand and show you a better way. Similarly with regex cutting down ambition usually cuts complexity very quickly.
Still code generators are cool tech and regex's computational simplicity could make a good stepping stone to more generally useful tools.
Thanks for sharing this, I really suck at writing Regex and have to use sites like https://regex101.com/ to relearn regex every time i wanna write even the simplest regex, so thanks man.
6 comments
1 u/nicky_haflinger 26 Jul 2015 22:33
I've never really had problems with regex, but I think that's because I treat them as a simple tool. I've seen people get in trouble trying to create pretend grammars or embed application logic in regex and that can range from headache to mathematical impossibility. Thinking of them as the arithmetic of strings clarifies most situations. If you are the kind of person that takes a float and runs it through a couple of pages of algebra to make web pages then someone needs to take you in hand and show you a better way. Similarly with regex cutting down ambition usually cuts complexity very quickly.
Still code generators are cool tech and regex's computational simplicity could make a good stepping stone to more generally useful tools.
0 u/14d2025 [OP] 26 Jul 2015 18:29
Check also: automatic regex golf player
0 u/zekio 26 Jul 2015 19:20
Thanks for sharing this, I really suck at writing Regex and have to use sites like https://regex101.com/ to relearn regex every time i wanna write even the simplest regex, so thanks man.
0 u/fluffingtonthefifth 26 Jul 2015 20:42
Uh ... ya, this is crap. :|
For the consonant case in this question, the generator returned this regular expression:
(?<=\w\w[^_][^_]\w\w\w\w )\w|(?<=\w\w\w\w\w \w\w\w\w\w\w )\w|\w(?=\w\w[^_]\w\w\w\w\w[^_]\w[^_]\w\w\w\w)|(?<=\w[\w][A-Za-z][A-Za-z] [A-Za-z])[A-Za-z](?=[A-Za-z][A-Za-z][A-Za-z][A-Za-z][A-Za-z] (?:\w))That doesn't even select what it's supposed to select.
I tried it a second time, for this result:
\w(?=\w\w\w\w\w\w\w\w)|\w(?=\w\w(?:\w\w)++\w)which is also bullshit.
0 u/zekio 26 Jul 2015 21:14
Damn, there is no way in hell I would ever understand a Regex with that many W's
0 u/bobsaguet 26 Jul 2015 23:38
But does the generated regex performs better in terms of CPU usage?