Regular is to deal with strings, using regular and convenient, and high performance
Define VAR reg=new RegExp (Rules, Options);//option can have no
Abbreviated VAR reg=/rules/options;
Options:
I ignore case
G looking from beginning to end
M Multi-line
Escaped: with \
\d represents a number
\w words
\s spaces
\d Non-digital
\w Non-word
\s Non-whitespace
Method:
Str.search (Regular) Look for no return-1
Str.math (regular) matches out, returns the object (array), if no match to the result returns null
Str.replace (Regular, WHO) represents the replacement
Quantifier: Specify several
{n} exactly n
{n,m} at least n max of M
{N,} at least N, up to an unlimited number of
? Dispensable
+ Several
* Can not, have an unlimited
Note: quantifiers just before one
Modified:
^ Beginning of the line
+ End of Line
\d Boundary
Note: ^ If no mate M is used, it refers to the beginning of the entire string
^ string wrapping is automatically recognized if mated with M
Square brackets ""
1 any A or B or C in "abc" ""
2 "0-9" This is the expression of an interval
3 "^ABC" excludes any other than a B C
Attention:
1^ $ to be higher than | priority
2 Do you implement a trim function? It means filtering the leading and trailing spaces
About regular Expressions