▲ | layer8 9 days ago | |||||||
Whenever I write a regex, I end up with a comments roughly ten times longer than the regex. That being said, regular expressions are often the right tool for the job (i.e. parsing a regular language, as opposed to a context-free language or whatever), just the syntax becomes unreadable rather quickly. I’m sure you could build a nicer regular-expression syntax in Haskell. | ||||||||
▲ | CBLT 9 days ago | parent | next [-] | |||||||
I love the verbose flag[0] to regex, so I can write comments inline. | ||||||||
▲ | f1shy 9 days ago | parent | prev | next [-] | |||||||
Yes. Regex tend to become rather fast write only. One solution is commenting, but is still complex. What I like to do now (in C) is define parts of it. Just a crude example to get the idea:
So at the end I compose the RE with the various parts, which are documented separately. | ||||||||
▲ | zokier 9 days ago | parent | prev [-] | |||||||
> just the syntax becomes unreadable rather quickly. I’m sure you could build a nicer regular-expression syntax in Haskell. Of course regular expressions are really more of a category of expressions, and the traditional kleene star notation is only one of many options; regular expressions do not somehow inherently need to use that specific syntax. Pomsky and VerbalExpressions are just some examples of alternative syntaxes for regex. Apparently there is even a port of VerbalExpressions for Haskell: https://github.com/VerbalExpressions/HaskellVerbalExpression... | ||||||||
|