0.0.18 • Published 3 years ago

naex v0.0.18

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

NaEx stands for "Natural Expressions" - it's an attempt to represent regular expressions in a way that is easier for a human to grasp and understand. Also, it limits the different ways you can use to represent the same thing, making it also easier to learn to use. Eventually, it compiles to a regular "regular expression"

how does it work

Instead of building one condensed string, you will use a set of TS function. For example, instead of writing this:

\((\w+:\s*\w+)

you need to write the following code:

const expression = literal(`(`) + group(
    oneOrMore(alnum)
    + literal(`:`)
    + zeroOrMore(space)
    + oneOrMore(alnum)
);

And this code will compile to the same regular expression, that you can use with RegExp class.

Yes, it's much longer, but it's immediately obvious what is going on.

0.0.18

3 years ago