For example, what is the difference between the {code...} symbols in [] and those outside? For example:
[\ W.] + and [\ w. + *?]
What is the difference between these symbols and the outside in?
Reply content:
For example:
[\ W.] + and [\ w. + *?]
What is the difference between these symbols and the outside in?
First, the Regular Expression[]
The content indicates the meaning of the optional combination,
Similar
/[\w.]/.test("a"); // true/[\w.]/.test("."); // true/[\w.]/.test("a."); // true/[\w.]/.test(" "); // false
The above regular expression can match one character or a dot in an optional combination, but cannot match null characters;
Differences:
1..
In[]
It is used to match.
It is used to match any character outside, as shown in the following example:
/./.test(" "); //true/[.]/.test(" "); //false
2.*
And+
In[]
It is called a quantizer (quantizer of a number). It indicates the quantity to be matched,
*
Indicates any number, and the Set indicates yes[0, +00)
;
+
Indicates at least 1 time, And the set indicates yes[1, +00)
;
It must be said that, when used as a quantizer,*
And+
Follow the regular expression (partial) that matches the meaning );
In[]
It indicates its own meaning, in order to match*
Or+
;
/[+]/.test("+"); //true/+/.test(""); //Uncaught SyntaxError: Invalid regular expression: /+/: Nothing to repeat(…)/.+/.test("oops"); //true