1. At the beginning and end of all of “/”, but at the end of “/” after the can with the specific expression of particular significance identifier. G such that patterns behind the increase is global.
2. Can be defined in two ways, for example, the following two, they are equivalent:
var pattern1: RegExp = / bob / i
var pattern2: RegExp = new RegExp (”bob”, “i”);
RegExp () in the two parameters, the second parameter that tag.
3. If the regular expression in “/”, etc., need to add in front of “\”, such as / 1 \ / 2 / that 1 / 2. (Like C + + in the escape character)
4. Metacharacters: ^ $ \. * +? () [] () | Regular expression that they have special significance. Brief list is as follows:
^ (Caret) Matches at the start of the string.
$ (Dollar sign) Matches at the end of the string.
\ (Backslash) Escapes the special metacharacter meaning of special characters.
. (Dot) Matches any single character.
* (Star) Matches the previous item repeated zero or more times.
+ (Plus) Matches the previous item repeated one or more times.
? (Question mark) Matches the previous item repeated zero or one time.
(And) Defines groups within the regular expression.
[And] Defines a character class, which defines possible matches for a single
character
| (Pipe) Used for alternation, to match either the part on the left side or the part on
the right side
5. Per sequence. In the regular expression in a sequence of characters with special meaning. Brief list is as follows:
(N) (n,) and (n, n) Used to identify a specific numeric quantifier or quantifier range for the previous item
\ A Matches at the start of the string to which the regular expression is applied
\ B Matches at the position between a word character and a non-word character
\ B Matches at the position between two word characters.
\ D Matches a digit.
\ D Matches any character other than a digit.
\ N Matches the newline character.
\ R Matches the return character.
\ S Matches any whitespace character (a space, tab, newline, or return character)
\ S Matches any character other than a whitespace character.
\ T Matches the tab character.
\ Unnnn Matches the Unicode character with the character code specified by the
hexidecimal number nnnn.
\ W Matches a word character (A-Z, a-z, 0-9, or _).
\ W Matches any character other than a word character.
\ Xnn Matches the character with the specified ASCII value, as defined by the
hexidecimal number nn.
\ Z Matches the end of the string to which the regular expression is applied.If the string ends with a line break, matches before the final line break.
\ Z Matches the end of the string to which the regular expression is applied.If the string ends with a line break, matches after the final line break.
6.regular expression of the flags.
Flag Property Description
g global Matches more than one match.
i ignoreCase Case-insensitive matching.
m multiline With this flag set, $ and ^ can match the beginning of a line and end of a line, respectively
s dotall With this flag set,. (dot) can match the newline character (\ n).
x extended Allows extended regular expressions.
7. Two methods: exec (), test (). test () is used to detect whether a string containing the characters to match, the return value is boolean value. exec () for pattern matching, and returns an array.