A.2 Regular Expressions

You can perform advanced text pattern matching using regular expressions. Regular expressions provide more flexibility than simple wildcard characters in defining rules or views. To match an exact regular expression character, precede the character with a backslash (\).

The following table lists regular expression operators and their definitions:

Menu Item

Character

Definition

Any Character

.

Matches any single character.

Character in Range

[ ]

Matches any single character from within the bracketed list. Within square brackets, most characters are interpreted literally.

Character Not in Range

[^]

Specifies a set of characters not to be matched.

Beginning of Line

^

Matches the beginning of a line.

End of Line

$

Matches the end of a line.

Or

|

Matches either the regular expression preceding it or the regular expression following it.

Group

( )

Groups one or more regular expressions to establish a logical regular expression consisting of sub‑regular expressions. Used to override the standard precedence of specific operators.

0 or 1 Matches

?

Specifies that the preceding regular expression is matched 0 or 1 time.

0 or More Matches

*

Specifies that the preceding regular expression is matched 0 or more times.

1 or More Matches

+

Specifies that the preceding regular expression is matched 1 or more times.

Exactly N Matches

{n}

Specifies that the preceding regular expression is matched exactly n number of times.

At Least N Matches

{n,}

Specifies that the preceding regular expression is matched n or more times.

At Most N Matches

{,n}

Specifies that the preceding regular expression is matched n or fewer times.

N to M Matches

{n,m}

Specifies that the preceding regular expression is matched a maximum of m times and a minimum of n times.

New Line Character

\n

Matches a new line.

Tab Character

\t

Matches a tab character.

The following table provides examples of regular expressions and matches.

Example

Matches

Does Not Match

st.n

Austin and Houston

Webster

st[io]n

Austin and Houston

Stanton

st[^io]n

Stanton

Houston or Austin

^houston

Houston

South Houston or Fort Sam Houston

ston$

Houston and Galveston

Stonewall

dall|hart

Dallas and Dalhart and Lockhart

Dale

dal(l|h)art

Dalhart

Dallas or Lockhart

il?e$

Etoile and Wylie

Beeville

il*e$

Etoile and Wylie and Beeville

Bellaire

il+e$

Etoile and Beeville

Wylie

ad{2}

Addison and Caddo

Adkins

(la.*){2,}

Highland Village and Lake Dallas

Laredo

il{,1}e$

Bowie and Etoile

Brownsville

(a.*){2,3}

Alamo Heights and La Blanca

Austin or Arkansas Pass

not ville

Houston and Dallas

Brownsville