instanceof REGEXP
REGEXP is a class in JS, similar to an array. However, this creation method does not specify the expression content
var re=new RegExp ();
The simplest regular expression that will match the letter A
Re=new RegExp ("a");
//Overloaded constructor whose second parameter specifies that the case is not case-sensitive
Re=new RegExp ("A", "I");
Among them, for the second parameter, optional parameters, including three kinds:
- G: Full text Search;
- I: Case insensitive;
- M: Multi-line search;
The more common rules for creating regular expressions are: the way literals are declared.
var re=/a/i; //Its effects are the same: Re=new RegExp ("A", "I"), and more commonly used.
Regular expression methods:
- Test method: Returns the Boolean type. It indicates whether the pattern is included in the string being searched. Returns true if present, otherwise false;
- Exec method: Uses the regular expression pattern to look in the string and returns an array that conforms to the regular expression pattern;
Regular Expression properties:
- Source property: Returns the text content of the regular expression. Read-only;
A String that matches the regular expression method:
- Match method: Finds the matching of one or more regular expressions, similar to the Exec method, returns an array
JS Regular notes