Regular Expressions

A regular expression is a search string that uses special characters to match patterns of text. The pattern must be a full match, not a partial match.

A simplified subset of regular expression syntax is shown below.

Character Description Find Matches
. Any single character

a.e

ave, ale, ate, etc.

*

Zero or more occurrences of the preceding characters

a*b

b, ab, aaab, etc.

+

One or more occurrences of the preceding characters

a+b

ab, aaab, etc.

?

Zero or one occurrence of the preceding characters

ca?b

cb, cab, etc.

{n}, {n,m}

 

 

A single character can be repeated a specific number of times:

a{n}  Matches 'a' repeated exactly n times

a{n,}  Matches 'a' repeated n or more times

a{n, m}  Matches 'a' repeated between n and m times inclusive

a{2,3}

 

aa, aaa

 

| Matches either of its arguments. Parenthesis can be used: abc|def

ab(d|ef)

abc, def

abd, abef

[]

^

Defines a set or range and matches any members of the set or range:

^ will match any character that is NOT in the specified set or range:

[abc]

[a-d]

[^a-d]

a, b, c

a, b, c, d

e, f, g, etc.

The following link also has more detailed information on Regular Expressions: http://msdn.microsoft.com/en-us/library/az24scfc.aspx