11
Character Meaning
Examples
character, and a blank.
*
Matches the preceding character or
character group zero or multiple
times.
"zo*" matches "z" and "zoo", and "(zo)*" matches
"zo" and "zozo".
+
Matches the preceding character or
character group one or multiple
times
"zo+" matches "zo" and "zoo", but not "z".
|
Matches the preceding or
succeeding character string
"def|int" only matches a character string containing
"def" or "int".
_
If it is at the beginning or the end of a
regular expression, it equals ^ or $.
In other cases, it equals comma,
space, round bracket, or curly
bracket.
"a_b" matches "a b" or "a(b"; "_ab" only matches
a line starting with "ab"; "ab_" only matches a line
ending with "ab".
-
It connects two values (the smaller
one before it and the bigger one
after it) to indicate a range together
with [ ].
"1-9" means 1 to 9 (inclusive); "a-h" means a to h
(inclusive).
[ ]
Matches a single character
contained within the brackets.
[16A] matches a string containing any character
among 1, 6, and A; [1-36A] matches a string
containing any character among 1, 2, 3, 6, and A (-
is a hyphen).
To match the character "]", put it at the beginning of
a string within brackets, for example [ ]
string
]. There
is no such limit on "[".
( )
A character group. It is usually used
with "+" or "*".
(123A) means a character group "123A";
"408(12)+" matches 40812 or 408121212. But it
does not match 408.
\index
Repeats the character string
specified by the index. A character
string refers to the string within ()
before \.
index
refers to the
sequence number (starting from 1
from left to right) of the character
group before \. If only one character
group appears before \,
index
can
only be 1; if n character groups
appear before
index
,
index
can be
any integer from 1 to n.
(
string
)\1 repeats
string
, and a matching string must
contain
stringstring.
(
string1
)(
string2
)\2 repeats
string2
, and a matching string must contain
string1string2string2.
(
string1
)(
string2
)\1\2
repeats
string1
and
string2
respectively, and a
matching string must contain
string1string2string1string2.
[^]
Matches a single character not
contained within the brackets.
[^16A] means to match a string containing any
character except 1, 6 or A, and the matching string
can also contain 1, 6 or A, but cannot contain these
three characters only. For example, [^16A] matches
"abc" and "m16", but not 1, 16, or 16A.
\<string
Matches a character string starting
with
string
.
"\<do" matches word "domain" and string "doa".
string\>
Matches a character string ending
with
string
.
"do\>" matches word "undo" and string "abcdo".