Special Operators and Regular Expressions

A regular expression is a formula for matching strings that have a certain pattern. It contains both normal alphabetic and numeric characters and metacharacters. Metacharacters are used to create the template pattern used in the search.

When you mark the Regular expressions check box, a button appears on the Find in Files interface, to the right of the Find what field. When you click this button, a pop-up list displays descriptions of various supported metacharacters.

BKBEBESRCH03-low.gif

Select a description from the list and the metacharacter is added to the Find what field. If you are familiar with Windows regular expression rules, you can also type in your own patterns.

The metacharacter options available from the pop-up list include:

Any Character

.

When the search function looks for a match for the specified string, any character is acceptable in this character position.
Character in Range

[]

Any of the characters between the brackets counts as a match for the search function.
Character Not in Range

[^]

Any character other than those listed between the brackets is an acceptable match.
Beginning of Line

^

Find the preceding search string only when it occurs at the beginning of a line.
End of Line

$

Find the preceding search string only when it occurs at the end of a line.
Beginning of Word

\<

Find the following search string only when it occurs at the beginning of a word.
End of Word

\>

Find the preceding search string only when it occurs at the end of a word.
Tagged Expression

\(\)

Treat the expression between \(and \) as a group.
0 or More Matches

*

Find zero or more occurrences of the preceding character.
1 or More Matches

+

Find one or more occurrences of the preceding character.
Quoted String

\

This is an escape character, used before a symbol that may be used as a metacharacter to indicate that it is being used as a literal. For example, if you were searching for any library routine, you could use “\$” to indicate the dollar sign character, rather than the end of line metacharacter.

Some sample expressions using regular expressions include:

^…$ Any line having three characters
[0-9] Any digit
[1-2].$ Strings where the second-to-last digit is “1” or “2”
[a-z] Any lowercase alphabetic character
^[A-C] Strings where the first character is an uppercase “A”, “B”, or “C”
[Ww]indow The strings “Window” or “window”

One useful, supported metacharacter not included in the regular expressions pop-up list is the pipe symbol (“|”). This is used between two separate search strings or search patterns to indicate that either of the two expressions is acceptable. The expression if|else, for example, will find any line that contains either the word if or the word else.