
Super-expressive: library for building regexes in (almost) natural language - kiyanwang
https://github.com/francisrstokes/super-expressive
======
IceDane
This is a great solution to what is mostly a non-problem. It's also not the
first one of its kind.

Regular expressions should be used so sparingly that you don't need an entire
library to write them safely. If you're ever writing a regular expression and
find yourself needing something like this to keep it under control, IMO you
should step back and consider just writing some actual code instead. Use a
proper parser if you're doing a complicated parsing job, or if you're doing
data validation, you can generally just reify your predicates as boolean
functions, or you might reach for something like joi or a similar library.

------
auganov
The rx macro in emacs is similar:
[https://francismurillo.github.io/2017-03-30-Exploring-
Emacs-...](https://francismurillo.github.io/2017-03-30-Exploring-Emacs-rx-
Macro/)

------
lifthrasiir

        SuperExpressive()
          .anythingButString('aeiou')
          .toRegex();
        // ->
        /(?:[^a][^e][^i][^o][^u])/
    

This is incorrect. It will match "frank" (that would be incorrect if the
method is supposed to avoid all vowels) and won't match "aeiuo" (that would be
incorrect if the method is supposed to accept anything but the exact string
"aeiou"). Assuming the latter was intended, the correct behavior depends on
the negation operator which is not natively supported in ECMAScript;
simulation is possible (as negation of regular language is still regular) but
at that point RegExp tends to be a bad solution.

------
pubby
The syntax seems strange to me. Why require .end() instead of using function
parenthesis?

.capture.anyOf.range('A', 'F').range('a', 'f').range('0', '9').end().end()

Could easily look like:

capture(anyOf(range('A', 'F'), range('a', 'f'), range('0', '9')))

