JavaScript regular expressions methods
In the following table, you can find the methods used to match or test a regular expression. The main JavaScript objects used in regular expressions are String
and RegExp
, which represent a pattern (such as regular expression
).
Method |
Description |
Example |
---|---|---|
|
This executes a search for a match within a string, based on a regular expression. |
|
|
This executes a search for a match in its string parameter. Unlike |
|
|
This searches and replaces the regular expression portion (match) with the replaced text instead. |
|
|
This breaks up a string into an array of substrings, based on a regular expression or fixed string. |
|
|
This tests for a match in a string. It returns the index of the match, or |
|
|
This tests whether the given string matches the Regexp, and returns true if it's matching, and false, if not. |
|
In this appendix, we very briefly covered the patterns learned throughout this book in a format that is easy to consult on a day-to-day basis.