regular expressions Definition

Regular expressions are combinations of special character operators, which are symbols that control the search, that you can use to construct search strings for advanced find and/or replace searches.

The regular expressions used to perform searches in the Quartus® Prime software are the same as those used in many Linux applications. For more information about regular expressions, see Jeffrey E.F. Friedl's Mastering Regular Expressions (Sebastopol: O'Reilly & Associates, Inc., 1997).

The table below shows examples of regular expression metacharacters, their descriptions, and their applications:

text-align:left;

Operator

Description

Example

. (dot)

Matches any single character of the input line.

.op finds top and hop, and it also finds the substring, top, in stop.

^

This metacharacter does not match any character but represents the beginning of the input line.

^A finds the letter A at the beginning of a line.

?

Matches a string of zero or one character that would match the character to the immediate left of ?.

m?y finds the substring y in the words, by and gray, and it also finds the entire word, my.

$

This metacharacter does not match any character but represents the end of an input line.

end$ finds end when it is the last string on a line.

\

This metacharacter is used to turn off the special meaning of metacharacters.

\. finds only the . (dot) character. \? finds only the ? character.

[...]

Matches one or more characters or a range of characters in the set.

[a-c]at finds bat and cat, but not sat.

[^...]

Matches one or more characters or a range of characters not in the set.

[^a-c]at finds sat and rat, but not bat or cat.

+

Matches a string of one or more characters that would match the character to the immediate left of +.

m+e finds me, but not made, mine, or more.

*

Matches a string of zero or more characters that would match the character to the immediate left of *.

m*y finds the substring y in the words, by and gray, and it also finds the entire word, my, as well as the substring, mmy, in the word, mummy.

The table below shows how to construct a regular expression search for special characters:

text-align:left;

To find:

Use the regular expression:

newline characters

\n

tabs

\t

.(dot), *, ?, ^, and other metacharacters used in regular expression searches

\., \*, \?, \^, and so on.