REGEXP
functionsupportedCore SQL functionsPerforms a comparison to determine whether a string matches or does not match a specified pattern. Both inputs must be text expressions. REGEXP is similar to the [ NOT ] LIKE function, but with POSIX extended regular expressions instead of SQL LIKE pattern syntax. It supports more complex matching conditions than LIKE. Tip You can use the search optimization service to improve the performance of queries that call this function. For details, see Search optimization service. Aliases: [ NOT ] RLIKE (2nd syntax) See also: String functions (regular expressions) REGEXP_COUNT , REGEXP_INSTR , REGEXP_REPLACE , REGEXP_SUBSTR [ NOT ] ILIKE , [ NOT ] LIKE
Syntax
<subject> [ NOT ] REGEXP <pattern>
Parameters
| Name | Required | Description |
|---|---|---|
subject | required | The string to search for matches. |
pattern | required | Pattern to match. For guidelines on specifying patterns, see String functions (regular expressions). |
Returns
Returns a BOOLEAN or NULL. - When REGEXP is specified, the value is TRUE if there is a match. Otherwise, returns FALSE. - When NOT REGEXP is specified, the value is TRUE if there is no match. Otherwise, returns FALSE. - When either REGEXP or NOT REGEXP is specified, returns NULL if any argument is NULL.
Usage notes
- The function implicitly anchors a pattern at both ends (for example, '' automatically becomes '^$', and 'ABC' automatically becomes '^ABC$'). For example, to match any string starting with ABC, the pattern is 'ABC.*'.
- The backslash character (\) is the escape character. For more information, see Specifying regular expressions in single-quoted string constants.
- For more usage notes, see the General usage notes for regular expression functions.
Collation Details
Arguments with collation specifications currently aren’t supported.