4 ms·
His examples were bad (asterisk etc.) but the point is valid. There is some hairy regular expression syntax that is pretty difficult to grok right off the bat.
by jqm 11y ago
His examples were bad (asterisk etc.) but the point is valid. There is some hairy regular expression syntax that is pretty difficult to grok right off the bat. It could be simpler and clearer.
- Retra 11y agoYou could say that about any syntax. But actually coming up with a better syntax is much harder than just saying it can be done.
- jqm 11y agoYou could say that about any syntax. But in most cases it would still apply much more to things like Perl regular expressions.
- vezzy-fnord 11y agoThere's VerbalExpressions, which simply wrap common PCRE tokens into methods/functions: https://github.com/VerbalExpressions https://github.com/VerbalExpressions
- Retra 11y agoThose are pretty good, if a little verbose.
- toufique 11y agoThis is awesome, like life-changing awesome! I always felt an impedance mismatch between how my mind describes string patterns and how regexps are written. VerbalExpressions is the closest thing I've seen to how I naturally think.
- techdragon 11y agoThis is going to rapidly replace every instance of regex in my code. The readability improvement is immeasurable. It's also conveniently similar enough to Python's verbose regex syntax.
- ivanhoe 11y agoNo one forces you to memorize every possible mnemonic, you remember the basic stuff that you use all the time, than you learn a bit more when you need it. And there is google for the rest, just like with everything else. And I seriously doubt that it could be made simpler and clearer for everyone, because we all come from different backgrounds and work on different things and our brains are by now hardwired to quickly handle different syntaxes. So it is a huge undertaking to rewrite something as complex as regexp to a completely new syntax and yet clearer and simpler to the majority of devs. Which of course doesn't mean one shouldn't try...