readable-regexp
Regular Expressions - quick and concise, readable and composable.
Features
๐ Readable
Be explicit and extract common pieces
Click to see examples
Compare a readable-regexp expression:
With normal JS RegExp:
In a more complex use case, we can destructure the expression into manageable small parts:
This is far more readable and debuggable than the equivalent RegExp:
๐ Flexible and Concise
Multiple shorthands and syntax options
Click to see examples
Without all the shorthands, an expression looks like this:
Whenever a function takes a single string literal, you can use a tagged template literal to remove the brackets:
When there is only one token in a quantifier or group, you can chain it with . instead of using a bracket:
There are shorthands for negating a character class or a lookaround:
As you can see, most of the distracting brackets are gone, and you are left with a clean and concise expression.
๐ Safe
Type check, auto-complete, and runtime safeguards
Last updated