Specifications
Summary of Special Characters
A summary of all the special characters is shown in Tables 4.4 and 4.5. Table 4.4 shows the
meaning of special characters outside square brackets, and Table 4.5 shows their meaning
when used inside square brackets.
TABLE 4.4 Summary of Special Characters Used in POSIX Regular Expressions
Outside Square Brackets
Character Meaning
\ Escape character
^ Match at start of string
$ Match at end of string
. Match any character except newline (\n)
| Start of alternative branch (read as OR)
( Start subpattern
) End subpattern
* Repeat 0 or more times
+ Repeat 1 or more times
{ Start min/max quantifier
} End min/max quantifier
TABLE 4.5 Summary of Special Characters Used in POSIX Regular Expressions Inside
Square Brackets
Character Meaning
\ Escape character
^ NOT, only if used in initial position
- Used to specify character ranges
Putting It All Together for the Smart Form
There are at least two possible uses of regular expressions in the Smart Form application. The
first use is to detect particular terms in the customer feedback. We can be slightly smarter
about this using regular expressions. Using a string function, we’d have to do three different
searches if we wanted to match on “shop”, “customer service”, or “retail”. With a regular
expression, we can match all three:
shop|customer service|retail
String Manipulation and Regular Expressions
C
HAPTER 4
4
S
TRING
M
ANIPULATION
113
06 7842 CH04 3/6/01 3:41 PM Page 113