The best JavaScript RegExp Object Tutorial In 2024, In this tutorial you can learn Complete RegExp Object Reference,What is RegExp?,grammar,RegExp Modifiers,Example 1,Example 2,Example 3,test (),Examples,Examples,exec (),Example 1,
RegExp: a regular expression (regular expression) shorthand.
Please see our JavaScript RegExp object reference manual , which provides all of the properties and methods can be used in conjunction with the string object.
This manual contains a detailed description and examples on the usage of each of the properties and methods.
A regular expression describes a pattern of characters of the object.
When you retrieve a text, you can use a model to describe the content to be retrieved. RegExp is this mode.
Simple pattern can be a single character.
More complex models include more characters can be used to parse, format check, replace, and so on.
You can specify a search string position, and the type of characters you want to retrieve, and so on.
Note: When using a constructor to create a regular objects, you need regular character escape rules (preceded by a backslash \). For example, the following are equivalent:
var re = new RegExp("\\w+"); var re = /\w+/;
Modifier is used to perform a case-insensitive and full-text search.
i - modifier is used to perform a case-insensitive match.
g - modifier is used to perform full-text searches (rather than finding the first stop to find, but to find all matches).
In a case-insensitive string find "W3CSchool"
The following text is marked matching expression obtained:
Full Text Search "is"
The following text is marked matching expression obtained:
Full Text Search and case-insensitive search "is"
The following text is marked matching expression obtained:
Value method specified search string test (), based on the results and returns true or false.
The following example is a search string from the character "e":
Because of the letter "e" in the string, the output of the code above will be:
When using a constructor to create a regular objects, you need regular character escape rules (preceded by a backslash \)
() Method to retrieve the specified value exec string. The return value is the value to be found. If no match is found, it returns null.
The following example is a search string from the character "e":
Because of the letter "e" in the string, the output of the code above will be: