|
Reference |
Sometimes searching for a literal string is too limiting. For example, you may want to search for a word starting at the beginning of a line or two words separated by any number of spaces. The text-based editors in SilverStream eXtend Workbench support the use of regular expressionspatterns for describing string matchingto augment the usual search capabilities.
This chapter includes the following sections:
NOTE Regular expression search is available in the Search>Find in Files dialog and in the Find dialog invoked from a native editor.
In addition to allowing you to type regular expression syntax directly into the Search for text box, the Find dialog has a regular expression helper menu you can use in constructing regular expression searches.
Selecting a helper menu item appends to the expression one or more characters that make up a syntactical building block. For most regular expression searches you will need to use several of these syntactical building blocks in combination with text you type directly into the Search for text box.
For more information on the regular expression helper menu items, see the
Regular expression reference.
NOTE When doing regular expression searches, you will not be able to use all the Find dialog search options. For example, the Match whole word option becomes meaningless, since this choice is made within the regular expression itself.
To use regular expressions in a search operation:
Select Search>Find in Files or select Search>Find in a native editor.
The Find dialog displays.
Select the Regular Expression check box.
OR
Click the right-arrow to the right of the Search for text box and make a selection from the regular expression helper menu.
Type a regular expression in the Search for text box, or use a combination of literal text and selections from the regular expression helper menu to construct your regular expression.
For example:
|
To match |
Enter |
|---|---|
void followed by main, with any amount of white space between the two words |
Text matching the search criteria appears highlighted in the Workbench editor.
The tables in this section explain the syntactical building blocks of regular expressions for Workbench. Many of these building blocks are available on the regular expression helper menu.
There are several categories of building blocks for regular expressions:
|
Syntax |
Description |
|---|---|
|
Syntax |
Description |
|---|---|
|
Syntax |
Description |
|---|---|
|
Syntax |
Description |
|---|---|
|
Syntax |
Description |
|---|---|
All closure operators (+, *, ?, {m,n}) are by default greedy, meaning that they match as many elements of the string as possible without causing the overall match to fail.
|
Syntax |
Description |
|---|---|
You can refer to the contents of a parenthesized expression within a regular expression itself using a backreference. The first backreference in a regular expression is denoted by \1, the second by \2, and so on. For example, the expression:
([0-9]+)=\1
will match any string of the form n=n (like 0=0 or 2=2).
|
Reference |
Copyright © 2002, SilverStream Software, Inc. All rights reserved.