-
Special Characters for Match Regular
Expression(
正则表达式
) and Search
and
Replace String
Use these
special characters in the
regular
expression
input of the
Match Regular Expression
and
Search
and Replace
String
functions. Right-click the
Search and Replace String function and select
Regular
Expression
from the shortcut
menu to configure the function for advanced
regular expression searches and
partial
match substitution in the replacement string.
Resize
the Match Regular
Expression function to view
any partial
matches found in the string. You can use the
Match Pattern
function or
the Match Regular
Expression function
to search strings for regular expressions. The
Match Regular Expression function gives
you more options for matching strings
but performs more slowly than the Match Pattern
function.
Note
The Match Regular Expression function does not
support null characters in strings. Also, a
pattern can return a successful match
of an empty string. If a pattern does not return a
successful
match, the
offset past match
will
return
–
1.
Regular expression support is provided
by the
PCRE library package
.
The license under which the PCRE
library package is redistributed can be
found on the
Copyright
page
at
Important
Information?
Copyright
on the
Contents
tab.
Refer to the PCRE Web site at for
more information about Perl Compatible Regular
Expressions.
Special
Character
.
Interpreted As
Matches any
single character except a newline character. For
example, .t matches at, bt, 2t, _t,
and
so on.
Marks part of a pattern as one
that can appear zero or more times in the input.
For example,
be* marks e as a pattern
that can appear 0 or more times. Therefore, be*
matches be in believe,
bee in beep, and
b in bat. In the last example, the e* did not
match a character, but the whole
match
still succeeded. This can be a problem if the
whole pattern is marked with an asterisk.
For example, the pattern b* matches b
in baac. The pattern b*, however, also matches an
empty string or abbc, returning a
successful match with
whole
match
returning an empty
string.
Marks part of a
pattern as one that can appear one or more times
in the input. For example, be+
matches
be in believe, bee in beep, and fails (no match)
with bat.
Marks part of a pattern as
one that can appear zero or one time in the input.
For example, be?
matches be in believe,
be in bee, be in beep, and b in bat.
Marks a part of a pattern as one that
can appear an arbitrary number of times in a
specific
range. For example, be{2}
matches b followed by at least two e characters.
be{0,3} matches b
followed by at most
three e characters. be{2,3} matches b followed by
at least two, but at most
three e
characters.
Creates character classes,
which allow you to match any one of a set of
characters. For
example, [abc123]
matches the characters a, b, c, 1, 2, or 3.
*
+
?
{ }
[]
-
Specifies a range of characters. For
example, [a-z] matches any lowercase letter.
[a-zA-Z0-9]
matches any lowercase or
uppercase letter or any digit.
You also can use a
character class to match any character not in a
given set by adding a caret
(^) to the
beginning of the class. For example, [^0-9]
matches any character that is not a digit.
[^a-zA-Z0-9] matches any character that
is not a lowercase or uppercase letter and also
not a
digit.
Indicates
partial matches. Separate possible matches in a
regular expression with a horizontal
bar (|). For example, (cat|dog) catcher
matches cat catcher or dog catcher and remembers
the
first part of the match (cat or
dog) in the first partial match.
You also can use multiple partial
matches.
For example,
(a|the) (cat|dog) matches a cat, a dog, the cat,
or the dog and remembers the first
word
(a or the) in the first partial match and the
second word (cat or dog) in the second partial
match.
((fire|police)(wo)?man) Smith matches
fireman Smith, policeman Smith, firewoman Smith,
or
policewoman Smith. partial match 1
is fireman, policeman, firewoman, or policewoman;
partial match 2 is fire or police; and
partial match 3 is
because the ?
indicates that wo can appear 0 or one times) or wo
(indicating a woman).
Indicates
multiple possible matches. For example, cat|dog
matches cat in catcher or dog in big
dog.
Anchors a match to the
beginning of a string. For example, ^dog matches
dog in dog catcher
but not the dog.
Anchors a match at the end of a string
when used as the last character of a pattern. For
example, dog$$ matches dog in the dog
but not dog catcher.
Cancels the
interpretation of any special character in this
list.
The following escaped
expressions have special meanings:
?
( )
|
^
$$
?
?
?
?
?
?
?
b - Represents
a word boundary. A word boundary is a character
that is not a word
character adjacent
to a character that is a word character and vice
versa. A word
character is an
alphanumeric character or an underscore (_). For
example, bhat
matches hat in hatchet
but not in that. hatb matches hat in that but not
in hatchet.
bhatb matches hat in hat
but not in that or hatchet.
c - Matches any control or non-printing
character; includes any code point in the
character set that does not represent a
written symbol
w - Matches
any word character; equivalent to [a-zA-Z0-9_]
W - Matches any non-word
character; equivalent to [^a-zA-Z0-9_]
d - Matches any digit character;
equivalent to [0-9]
D -
Matches any non-digit character; equivalent to
[^0-9]
s - Matches any
white space character; includes space, newline,
tab, carriage return,
and so on
S - Matches any non-white
space character
-
-
-
-
-
-
-
-
-
上一篇:2020届高考英语二轮复习专题一阅读第3讲词义猜测题练习
下一篇:介词测试题及答案