regex_match function
The regex_match function returns indicates whether a source string matches the regular expression.
Syntax
regex_match(
str lvarchar,
re lvarchar,
copts integer DEFAULT 1)
returns boolean
regex_match(
str clob,
re lvarchar,
copts_string lvarchar)
returns boolean
Parameters
- str
- The string to search. Can be of type CHAR, NCHAR, VARCHAR, NVARCHAR, LVARCHAR or CLOB. A null value is treated as an empty string.
- re
- The regular expression. Can be of type CHAR, NCHAR, VARCHAR, NVARCHAR, or LVARCHAR. Cannot be null.
- copts (Optional)
- The type of regex search:
- 0 = Basic regex
- 1 = Default. Extended POSIX regex
- 2 = Basic regex and ignore case
- 3 = Extended POSIX regex and ignore case
- copts_string (Optional)
- The type of regex search:
- basic = Basic regex
- extended = Default. Extended POSIX regex
- basic,icase = Basic regex and ignore case
- extended,icase = Extended POSIX regex and ignore case
- basic,rtrim = Basic regex with rtrim
- extended,rtrim = Extended POSIX regex with rtrim
- basic,icase,rtrim = Basic regex and ignore case with rtrim
- extended,icase,rtrim = Extended POSIX regex and ignore case with rtrim
Description
Use the regex_match function to determine if the source string matches the regular expression.
Returns
t = The source string matches the regular expression.
f = The source string does not match the regular expression.
An exception = An error occurred.
Example
The following statement tests whether the word "module", "Module", or "DataBlade" occurs in the
string:
execute function regex_match
('Regex module' , '[Mm]odule|DataBlade');
(expression) t
In the following example, the regular expression
'wo[ou]l?d'
matches the word
"wood" and the word
"would":select id, twister
from tongue_twisters
where regex_match(twister, 'wo[ou]l?d');
id 286
twister If two witches would watch two watches, which witch
would watch which watch?
id 335
twister How much wood could a woodchuck chuck if a
woodchuck could chuck wood? A woodchuck
could chuck as much wood as a woodchuck would
chuck if a woodchuck could chuck wood.