Skip to content

Commit

Permalink
Update fail-faster.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Mar 18, 2018
1 parent 667d4e6 commit 78dc435
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/regexp/fail-faster.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ Reduce the use of `|` using character classes and optional components, or by pus

Everyone knows `RegExp` are difficult to write. A good approach to write the right `RegExp` is to automate the process.

[regexgen](https://github.com/devongovett/regexgen#regexgen) is a good library for that: it generates a tree structure based on the input and generates the most optimized `RegexEp`, removing redundancies.

See it in action from your CLI:
[regexgen](https://github.com/devongovett/regexgen#regexgen) is a good library for that: it generates a tree structure based on the input and generates the most optimized `RegexEp`, removing redundancies:

```bash
$ regexgen wave freewave freestylewave "freestyle wave"
/(?:free(?:style ?)?)?wave/
```

You can combine it with [randexp](https://github.com/fent/randexp.js) to generates random strings that match a given RegExp:

```js
const RandExp = require('randexp');
new RandExp(/hello+ (world|to you)/).gen();
// => hellooooooooooooooooooo world
```

0 comments on commit 78dc435

Please sign in to comment.