Regular Expressions For Finding and Replacing Text

See Also

You can use regular expresssions to add flexibility to searches in the IDE. Regular expressions are composed of a special syntax that enables you to express a wide range of search patterns.

In the Find in Projects dialog box, you can use regular expressions to match file names or file text. In the Find dialog box and the Replace dialog box, you can use regular expressions to help you perform search and replace operations.

Regular Expression Constructs

See the table below for some descriptions of special characters in regular expressions.

Construct Description
|Or.
^Matches text beginning with the subsequent characters.
$Matches text ending with the preceding characters.
\Escape character. Necessary if you want to match to a period (.), bracket ([), brace (() or other special character.
\nNew-line character
\rCarriage-return character
[]Used to delimit a set of characters.
*Zero or more occurrences of the previous character or set of characters.
+One or more occurrences of the previous character or set of characters.
.*Wildcard.

For a more complete list of regular expression constructs and further discussion of regular expressions, see http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum.

Sample Regular Expressions

The table below contains some examples of regular expressions that you might use in file searches.

Regular Expression Matches
"[^"\r\n]*" Matches (quoted) strings in the document.
\{[^\{\}]*\} Inner block of code between braces ({}). Blocks with nested braces are not matched.
[ \t]+$ All white space at the end of lines.
See Also
Finding and Replacing Text
Finding Class, Method, and Field Usages

Legal Notices