Predefined classes match common character classes.
Common predefined class characters are:. All characters except carriage return and line break
\d Numeric characters
\d non-numeric characters
\s whitespace characters
\s non-whitespace characters
\w Word characters (such as numbers, letters, and underscores)
\w non-word characters
Regular expressions also provide several commonly used bounds-matching characters, such as: ^ previously started
$ start at the end
\b Word boundaries
\b Non-word boundaries
Non-greedy mode: Let the regular expression match as few as possible, once the match succeeds, no longer matches.
Greedy mode: Let the regular expression match as many matches as possible, matching all matches.
change the non-greedy mode to greedy mode add a question mark after the quantifier, such as: {3,8} ? .
Use () to group, so that quantifiers act on groupings, such as :(my) {3} the words in parentheses are repeated three times.
Use | choose her or him, or the meaning. such as (m|y) select m or y.
reverse references, such as:2017-06-28=>06/28/2017
write ' 2017-06-28 '. Replace (/(\d{4})-(\d{2})-(\d{2})/g, ' $2$3$1 ')
Ignore grouping: Do not want to capture certain groupings, add a question mark within the grouping, such as :(?: my). (OK)
The common quantifiers are:? Occurs 0 or more times (up to one time)
+ occurs one or more times (appears at least once)
* appears 0 or more times (any time)
{N,} appears at least once
{n} appears n times
{N,m} appears n to M times
The regular expression is parsed from the head of the text to the end, and the end of the text is called the front.
The forward-looking is when the regular expression matches the rule and checks forward to see if the assertion is met.
Post-Juniper is in the opposite direction, and JavaScript does not support post-juniper.
Compliant and non-conforming specific assertions are called positive or positive matching and negative or no matching.
Altogether there are: forward-looking exp (? =assert)
Negative forward exp (?! =assert)
Forward Looking back exp (? <=assert)
Negative to looking back exp (? <!assert)
JavaScript Regular Expression Two