Skip to content

Commit

Permalink
Update correct-methods.md
Browse files Browse the repository at this point in the history
  • Loading branch information
miparnisari authored Nov 14, 2016
1 parent eb98f50 commit b310d62
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions regexp/correct-methods.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Use the correct `RegExp` method

In general terms:
In general:

- Use `.test` if you want a faster boolean check.
- Use `.match` to retrieve all matches when using the g global flag.
- Use `.test` if you want a fast boolean check.
- Use `.match` to retrieve all matches when using the `g` flag.

> It's possible that you can gain an extra of perfomance using String method to match `RegExp` instead of RegExp to match String. It's depends of your case of use 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) & [test#3](https://jsperf.com/test-vs-indexof-fast/5) benchmarks.
> 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.

0 comments on commit b310d62

Please sign in to comment.