/* Regular expression is an object that describes the character pattern.
Regular expressions are used for string pattern matching and retrieval substitution, and are powerful tools for performing pattern matching on strings.
/* Syntax
var patt=new RegExp (pattern,modifiers);
Or in a simpler way:
var patt=/pattern/modifiers;
The modifiers values are as follows:
I perform a match on case insensitive.
G performs a global match (finds all matches rather than stops after the first match is found).
M performs multi-line matching.
For example:
var patt =/aaaa/i;
Alert (Patt.test ("AAAA")); Result is True
var patt2 =/aaaa/;
Alert (Patt2.test ("AAAA")); The result is false
*/
/* Most characters regular in the expression, that is, the literal meaning, such as/a/match a,/b/match b
But there are also characters that have a special meaning in addition to the literal meaning that these characters are meta-characters
In JavaScript, a total of 14 metacharacters (Meta-character)
() [] {} \ ^ $ | ? * + .
Meta-character name matching object
. Dot single arbitrary character (except carriage return \ r, newline \ n, line delimiter \u2028, and segment delimiter \u2029)
A single arbitrary character listed by the [] character group
[^] Excluded character groups are not listed as a single arbitrary character
? Question mark matches 0 or 1 times
* Asterisks match 0-handed or multiple times
+ PLUS sign matches 1 or more times
{Min,max} interval quantifier matches at least min times, max Times
^ The starting position of the caret lines
$ USD Lines End position
| A vertical bar separates any expression on either side
() brackets restrict the range of multi-select structures, the elements that mark the action of quantifiers, and capture text for a reverse reference
\1,\2 ... The reverse reference matches the first, second ... Text that matches an expression within a group of parentheses
* */
JavaScript Regular Expressions