Chapter 5 Using the PowerDesigner Interface


Finding text using regular expressions

A regular expression is a pattern of text that describes one or more strings to match when searching for text. You can use regular expressions to find script text displayed in the Preview or Script tab of a table property sheet, the Edit/Run Script editor, the Resource Editor, and various other windows.

In order to be able to search for text using regular expressions, you must select the Regular Expression check box in the Find dialog box (or Replace in Items dialog box in the Resource Editor) and type a regular expression in the Find What box.

Regular expressions can contain ordinary characters and the following metacharacters :

Metacharacter Description
\ Matches a special character

Examples:

"n" matches "n". "\n" matches a newline character. "\\" matches "\" and "\(" matches "("
^ Matches the position at the beginning of the input string

Examples:

"^Win" matches strings beginning with "Win
$ Matches the position at the end of the input string

Examples:

"then$" matches strings ending with "then"
* Matches the preceding character zero or more times

Examples:

"zo*" matches "z" and "zoo"
+ Matches the preceding character one or more times

Examples:

"zo+" matches "zo" and "zoo", but not "z"
? Matches the preceding character zero or one time

Examples:

"to?" matches either "t" or "to"
. Matches any single character except the newline \n

Examples:

".ork" matches "Work", "Fork" etc
[ ] Matches any one of the enclosed character

Examples:

"[abc]" matches "a", "b", or "c"
A range of character can be indicated with a dash "[a-z]"

For a complete list of metacharacters and their behavior in regular expressions, see the Visual Basic Documentation .

 


Copyright (C) 2007. Sybase Inc. All rights reserved.