DEV Community

Discussion on: VerbalExpressions - RegularExpression made easy

Collapse
 
moopet profile image
Ben Sinclair

I don't hate the idea of these, but I do find them awkward.

When I read anythingBut(' ') I wonder, does it mean [^ ] or [^ ]+ or [^ ]*? How do I tell it that I mean any whitespace, like \s instead of a space? How is it clear that maybe(' ') and maybe(' ') are different1 and mean spaces and tabs respectively?

Back references? Discarded groups? All that shenanigans? I think I'd spend longer looking up how to do something with this sort of wrapper than I would just using regex in the first place. You can split regex over lines and add comments for them, so there shouldn't be any ambiguity. You can test them just like you test anything else.

To me, verbal expressions seem like a cut-down wrapper rather than an abstraction, and I'm not sure how they would help in anything but the simplest cases.


  1. Pretend there's a tab in that, I can't put one in markdown :)