Skip to content

Finding Text Using Regular Expressions

Regular Expression Syntax Rules

The editor's Find and Find & Replace operations support using regular expressions when specifying the text that is to be searched.

The Studio's regular expression implementation is a partial implementation of Perl regular expressions. The following syntax rules are supported:

Metacharacters

\       Quote the next metacharacter
.       Match any character
|       Alternation (ORd expression)
()      Grouping
[]      Set of characters. For example,[0123a-z]will match 0, 1, 2, 3, and all lowercase alphabet characters. If the first character is^, none of the specified characters must be present in order to match.
^       Match the beginning of the line.
$       Match the end of the line.

Quantifiers (Greedy)

*       Match 0 or more times
+       Match 1 or more times
?       Match 0 or 1 times
{n}     Match exactly n times
{n,}    Match at least n times
{n,m}   Match at least n but not more than m times

By default, a quantified subpattern is “greedy,” meaning it will match as many times as possible while still allowing the rest of the pattern to match. If you wish for a regular expression to match the minimum number of times possible, follow the quantifier with a question mark (‘?’).

Quantifiers (Non-Greedy)

*?      Match 0 or more times
+?      Match 1 or more times
??      Match 0 or 1 times
{n}?    Match exactly n times
{n,}?   Match at least n times
{n,m}?  Match at least n but not more than m times

Escape Sequences

\t      Match a tab character
\w      Match a "word" character (alphanumeric plus "_")
\W      Match a non-"word" character
\s      Match a whitespace character
\S      Match a non-whitespace character
\d      Match a digit character
\D      Match a non-digit character
\b      Match a word boundary
\B      Match a non-word boundary
\a      Match only at the beginning of the line
\z      Match only at the end of the line

See Also