The MATCHES predicate performs SQL queries using regular expression pattern matching. This type of pattern matching is more powerful than the wildcard pattern matching available with the LIKE predicate.
MATCHES (Column_Reference, ' { Grouped_Search_Pattern | Counted_Search_Pattern } ') > 0
Column_Reference | Specifies the column name (alias). Its data type must be compatible with the format of the Search_Pattern specified. |
Grouped_Search_Pattern | Specifies matches against multiple patterns. |
Counted_Search_Pattern | Specifies searches for repetitions of the same pattern. You can request:
|
A grouped or counted search pattern is formed like a literal of type Basic String but consists of a combination of characters and regular expressions (match symbols). Index Server is not case sensitive to characters in a search pattern other than the match symbols. The following table lists and describes the regular expressions that you can use with the MATCH predicate:
Name | Symbol | Description |
---|---|---|
Asterisk | * | Matches 0 or more occurrences of the search pattern. |
Question mark | ? | Matches 0 or 1 occurrence of the preceding pattern. |
Plus sign | + | Matches 1 or more occurrences of the preceding pattern. |
Parentheses | ( ) | Use to delimit search patterns > 1 character. |
Curly braces | { } | Use to delimit a counted match. |
Square Brackets | [ ] | Use to specify a range of characters in a pattern. |
Vertical bar | | | Use as an escape character that must precede any of the above symbols. Commas separating OR clauses in the matching terms must also be preceded the escape character. |
The following example uses a grouped match. The pattern matches authors with the names "McAlister", and "McAllister" (names such as "McAlllister", if they existed, would also be matched). Note how the vertical-bar escape character precedes the embedded parentheses, as well as the commas.
...WHERE MATCHES (DocAuthor, '(MacAl|+ister' )> 0
The following example matches any string in which exactly three instances of the pattern "Bora" occur.
...WHERE MATCHES (DocText, '|(Bora|)|{3|}' ) > 0
The following example matches any string in which at least two instances of the pattern "Bora" occurs.
...WHERE MATCHES (DocText, '|(Bora|)|{2,|}' ) > 0
The following example matches any string in which between two and three instances of the pattern "Bora" occurs.
...WHERE MATCHES (DocText, '|(Bora|)|{2,3|}' ) > 0