Matching text patterns

A text pattern is an expression that you can use to evaluate whether a string contains a particular pattern of characters. Text patterns consist of metacharacters, which have special meaning, and characters (nonmetacharacters). The way the metacharacters and normal characters are combined specify the pattern you are looking for.

Metacharacters

Valid metacharacters are:

Nonmetacharacters

In a text pattern, you can also use characters that are not metacharacters. One or more nonmetacharacters in a text pattern (such as letters) match the characters themselves. For example, A matches A, and ABC matches ABC.

Examples

Text patterns are needed in all expressions that use the Match function. Text patterns are used in validation rules in the Form painter (in a column object’s Validation property page) and the Database painter (in the Match Pattern dialog box). For information about the Match function, see Match.

The following table shows various text patterns and sample text that matches each pattern:

Table 23-13: Matching text patterns in InfoMaker expressions

This pattern

Matches

AB

Any string that contains AB; for example, ABA, DEABC, graphAB_one.

B*

Any string that contains 0 or more Bs; for example, AC, B, BB, BBB, ABBBC, and so on.

AB*C

Any string containing the pattern AC or ABC or ABBC, and so on (0 or more Bs).

AB+C

Any string containing the pattern ABC or ABBC or ABBBC, and so on (1 or more Bs).

ABB*C

Any string containing the pattern ABC or ABBC or ABBBC, and so on (1 B plus 0 or more Bs).

^AB

Any string starting with AB.

AB?C

Any string containing the pattern AC or ABC (0 or 1 B).

^[ABC]

Any string starting with A, B, or C.

[^ABC]

A string containing any characters other than A, B, or C.

^[^abc]

A string that begins with any character except a, b, or c.

^[^a-z]$

Any single-character string that is not a lowercase letter (^ and $ indicate the beginning and end of the string).

[A-Z]+

Any string with one or more uppercase letters.

^[0-9]+$

Any string consisting only of digits.

^[0-9][0-9][0-9]$

Any string consisting of exactly three digits.

^([0-9][0-9][0-9])$

Any string consisting of exactly three digits enclosed in parentheses.