|
Use :( Here are some important use metacharacters)
\ S whitespace characters: a space character, \\ s: a plurality of spaces, \\ s +: a plurality of spaces
\ T tab ( '\ u0009')
\ N new line (line feed) character ( '\ u000A')
\ R carriage return ( '\ u000D')
\ F feed character ( '\ u000C')
\ A alert (bell) character ( '\ u0007')
\ B matches a word boundary (located to find a word beginning or end of the match)
\ D: to match the numbers from 0 to 9;
\ W: to match letters, numbers, or the underscore character (a-zA-Z0-9_)
\ E escape character ( '\ u001B')
\ Cx The control character corresponding to x
\ U00A9 is Unicode character
: Match all characters except newline
(To match all characters except newline)
Match string:
var s = 'abc efg';
var r = s.match (/ absc / ig); // => get absc
Convert a string:
s.replace (r, '1') // => var s = '1 efg' successfully replaced
egrep metacharacters
Matches any single character
. Dot matches any single character
[...] Character class matches a single character listed
[^ ...] Negated character set matches a single character that is not listed
Yuan character count feature
? The question mark matches the time allowed, but not necessarily
* The asterisk matches any number of times, it may not match
+ Plus at least one match, at least as many times as possible
{Min, max} interval quantifier requires at least min and at most max times allowed
Metacharacter matches the location
Caret ^ matches the beginning of a line position
$ Dollar sign matches the end position line
\
\> End of a word delimiter matching words
Other characters
| Alternation matches any partition expression
Chinese Regular: / ^ [\ u4E00- \ u9FA5] + $ / |
|
|
|