[CyberSource logo]


Search documentation:

  Help  Advanced
        Published 08/06/2002 Table of ContentsPreviousNextIndex

Appendix A

Regular Expressions

This chapter provides a brief introduction to regular expressions.

Regular Expressions

The REGEX operator uses regular expressions to evaluate the contents of a field. Regular expressions test whether the contents match a pattern that you specify. If a field's contents match a regular expression, the rule returns true.

Regular expressions contain the following types of information:

Metacharacters

Table 11 shows some metacharacters that are often used in regular expressions.



Table 11 Regular Expression Metacharacters 
Character
Description
Example
.
Matches any single character.
b.g matches bug, bag, and bog. It does not match bg or boogie.
*
Matches zero or more occurrences of the preceding character (which can also be a metacharacter).
bugs* matches bugs, bugss, and bugsy. It does not match bugout.
^
Matches the beginning of the string.
^tooth matches toothpaste and toothbrush. It does not match falsetooth.
$
Matches the end of the string.
bag$ matches totebag and sportbag. It does not match baggie.
\
Indicates that the following character should not be treated as a metacharacter.
test\* matches test*. It does not match testt or testtt.
[ ]
A set of characters, only one of which is needed for a match.
bu[gt] matches bug and but. It does not match bun, buzz, or butter.
number[0-9] matches number3 and number7. It does not match numbers.
+
Matches one or more occurrences of the preceding character (which can also be a metacharacter).
ba+g matches bag and baaggie. It does not match bg or baieg.
?
Matches zero or more occurrences of the preceding character (which can also be a metacharacter).
ba?g matches bag and bg. It does not match baaggie or baeig.


Copyright © 2002 CyberSource Corporation.
TOC PREV NEXT INDEX