Using regular expressions
109
•
Any regular expression can be followed by one of the following suffixes:
−
{m,n} forces a match of m through n (inclusive) occurrences of the preceding
regular expression
−
{m,} forces a match of at least m occurrences of the preceding regular
expression
The syntax {,n} is not allowed.
•
A range of characters can be indicated with a dash. For example,
[a-z]
matches
any lowercase letter. However, if the first character of the set is the caret (^), the
RegExp matches any character except those in the set. It does not match the
empty string. For example,
[^akm]
matches any character except
a
,
k
, or
m
. The
caret loses its special meaning if it is not the first character of the set.
•
All regular expressions can be made case-insensitive by substituting individual
characters with character sets, for example,
[Nn][Ii][Cc][Kk]
.
Using a character class
You can specify a character by using a POSIX character class. You enclose the
character class name inside two square brackets, as in this example:
"Macromedia’s Website","[[:space:]]","*","ALL")
This code replaces all the spaces with *, producing this string:
Macromedia’s*Website
The following table shows the supported POSIX character classes:
Character
class
Matches
alpha
Any letter, [A-Za-z]
upper
Any uppercase letter, [A-Z]
lower
Any lowercase letter, [a-z]
digit
Any digit, [0-9]
alnum
Any alphanumeric character, [A-Za-z0-9]
xdigit
Any hexadecimal digit, [0-9A-Fa-f]
space
A tab, new line, vertical tab, form feed, carriage return, or space
Any printable character
punct
Any punctuation character:
! ‘ # S % & ‘ ( ) * + , - . / : ; < = > ? @ [ / ] ^ _ { | } ~
graph
Any character defined as a printable character except those defined as
part of the
space
character class
cntrl
Any character not part of the character classes:
[:upper:], [:lower:], [:alpha:], [:digit:], [:punct:], [:graph:], [:print:], [:xdigit:]
Содержание HOMESITE
Страница 11: ...Contents xi Table of CommandID values 310 Table of SettingID values 314 Glossary 323...
Страница 12: ...xii Contents...
Страница 20: ...xx About This Book...
Страница 28: ...8 Chapter 1 Setting Up the Product...
Страница 70: ...50 Chapter 4 Managing Files...
Страница 88: ...68 Chapter 5 Writing Code and Web Content...
Страница 116: ...96 Chapter 6 Editing Pages...
Страница 148: ...128 Chapter 7 Using Web Development Languages...
Страница 190: ...170 Chapter 11 Deploying Files...
Страница 210: ...190 Chapter 12 Testing and Maintaining Web Pages...
Страница 216: ...196 Chapter 13 Extending the Help System...
Страница 350: ...330 Glossary...
Страница 358: ...338 Index...