Readable Regular Expressions for JavaScript/TypeScript, Inspired by Emacs' rx
10 points by confusedalex
10 points by confusedalex
i really like this kind of type-checked and very clear regex engineering in theory, but in practice i find little use for them for a couple of reasons:
seq(someBeginToken, capture(oneOrMore(not(someEndToken))), someEndToken) or just a match against a fairly legible log line with one or more capturing groups like Invalid user .* from ([0-9.]+) port .*. to someone who frequently reads/writes regex the direct regex syntax will likely be easier to understand, since it is more terse and the regex is more closely aligned with what one is actually parsing.java.util.Pattern.COMMENT).* just means "basically anything and however much of it", and so will everyone else i am working with. custom abstraction layers on top are often a new concept and introduce their own idiosyncrasies. sharing normal regexes (as long as they dont use too many weird regex extensions) between projects is also a lot easier.i still like things like this, but because of those associated costs i never end up using them in any real projects
It's way nicer but also if you've made an API that looks like this, I think you may as well go a little further and make it create parser combinators like Parsec's style or LL(1-or-more) parsers because they tend to be very readable too for exactly the same reason..