Regular expressions
1. mode
/reg/i Ignore Case
/reg/g, Get all
/reg/m, can put \ n as multiple lines
2. Brackets
[] or
[^] except
lin[^ux]x; can match to Lin X , meaning that the spaces here are contained in [^ux] in
3. parentheses
() delineation range
Backward reference
$ , A string that represents the first parenthesis in a match
4. Meta- characters
. any character except for the line break
\w a character that represents any number of letters and underscores [a-za-z0-9_]
\w represents other characters except for numeric letters and underscores [^a-za-z0-9_]
\d Find Numbers [0-9]
\d find non-numeric characters [^0-9]
\s Find white space characters []
\s find non-whitespace characters [^]
\ n Find line breaks
\b represents the word boundary, which must be space on both sides of the word /\bp.p\b/ig
\b represents a non-word boundary
\xxx octal
\XDD hexadecimal
\uxxx Chinese Code
5. quantifiers
? 1 one or 0 a {0,1}
+1 one or more {1,}
* 0 a 1 one or more {0,}
.* blur matches multiple characters
.*? Exact Match
{n} n
{1,n} 1 to the N a
End $
beginning ^
(? =n) match the subsequent existence N part of
(!? =n) above counter-
This article is from the "rcid" blog, make sure to keep this source http://13419255.blog.51cto.com/13409255/1975760
JS Regular expression