11. Report-Writer Expressions and Formats : Operations : Comparison Operators : Pattern Matching with Wild Cards
 
Share this page                  
Pattern Matching with Wild Cards
You can indicate partial matches of character string data in a conditional clause in an .if statement and in the where clause of a query by using special wild card characters with the comparison operators. The character string data must be delimited by single quotes (except when used in a QUEL query).
Wild Cards in an .If Clause
When used in a string within an .if condition, the special meaning of wild card characters can be disabled by preceding them with a backslash (\) character. Report-Writer then interprets the wild card character literally. Thus, \* refers to the asterisk character. When used outside of an .if condition, wild card characters have no special meaning and are always interpreted literally.
You can use the following wild card characters within a conditional clause in an .if statement for the purpose of comparing character string data:
Character
Description
*
Matches any string of zero or more characters
?
Matches any single character
[..]
Matches any of the characters in the brackets
Any of these special characters can be used alone or in combination to specify partial match criteria:
Example
Description
ename = '*'
Matches all values in the "ename" column
ename = 'E*'
Matches any value beginning with "E"
ename = '*ein'
Matches any value ending with "ein"
ename = '*[aeiou]*'
Matches any value with at least one vowel
ename = 'Br???'
Matches any five-character value beginning with "Br"
ename = '[A-J]*'
Matches any value beginning with A, B, C, ..., J
ename = '[N-Z]???'
Matches any four-character value beginning with N, O, P, ..., Z
You cannot use blanks in bracketed expressions such as "[A‑J]*" or "[N-Z]???".
Wild Cards in Queries
When a string appears within the where clause of a .query statement, the wild card conventions must follow those of the database query language you are using to retrieve the data.