Skip to content

Commit

Permalink
Fixed wording in /regexp.
Browse files Browse the repository at this point in the history
  • Loading branch information
kerwitz committed Jun 14, 2017
1 parent 99a79cd commit 5c48014
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/regexp/correct-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ In general:
- Use `.test` if you want a fast boolean check.
- Use `.match` to retrieve all matches when using the `g` flag.

!> It is possible to gain extra perfomance using `String` method to match `RegExp` instead of `RegExp` to match `String`. It depends on your use case and of your JavaScript engine. Check [test#1](https://jsperf.com/regexp-test-search-vs-indexof/12), [test#2](https://jsperf.com/regex-methods-x-1/2) and [test#3](https://jsperf.com/test-vs-indexof-fast/5) benchmarks.
!> It is possible to gain extra performance using `String` method to match `RegExp` instead of `RegExp` to match `String`. It depends on your use case as well as your JavaScript engine. Check [test#1](https://jsperf.com/regexp-test-search-vs-indexof/12), [test#2](https://jsperf.com/regex-methods-x-1/2) and [test#3](https://jsperf.com/test-vs-indexof-fast/5) benchmarks.
6 changes: 3 additions & 3 deletions docs/regexp/fail-faster.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Slow `RegExp` processing is usually caused by slow failure rather than slow matching.

Reduce the use of `|` using character classes and optional components, or by pushing the alternation further back into the `RegExp` (allowing some match attemps to fail before reaching the alternation):
Reduce the use of `|` using character classes and optional components, or by pushing the alternation further back into the `RegExp` (allowing some match attempts to fail before reaching the alternation):

| Instead of | Use |
|-----------------------|-----------------|
Expand All @@ -11,9 +11,9 @@ Reduce the use of `|` using character classes and optional components, or by pus
| red|raw | r(?:ed|aw) |
| (.\|\r\|\n) | [\s\S] |

All people known `RegExp` are difficult to write. A good approach for write the right `RegExp` is automate the process.
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's generate a Trie structure based on the input and generate the most optimized `RegexEp`, removing redundancies.
[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:

Expand Down

0 comments on commit 5c48014

Please sign in to comment.