- Categories:
REGEXP_LIKE¶
Returns true if the subject matches the pattern. Both expressions must be text expressions.
- Aliases
RLIKE (1st syntax)
See also String Functions (Regular Expressions).
Syntax¶
REGEXP_LIKE( <subject> , <pattern> [ , <parameters> ] )
Usage Notes¶
The function implicitly anchors a pattern at both ends (i.e.
''
automatically becomes'^$'
, and'ABC'
automatically becomes'^ABC$'
). To match any string starting with ABC, the pattern would be'ABC.*'
.For more usage notes, see the General Usage Notes for regular expression functions.
Collation Details¶
Arguments with collation specifications are currently not supported.
Examples¶
-- Example setup
CREATE OR REPLACE TABLE rlike_ex(city varchar(20));
INSERT INTO rlike_ex VALUES ('Sacramento'), ('San Francisco'), ('San Jose'), (null);
-- Case-sensitive pattern matching with wildcards
SELECT * FROM rlike_ex WHERE REGEXP_LIKE(city, 'san.*');
+------+
| CITY |
|------|
+------+
-- Case-insensitive pattern matching with wildcards
SELECT * FROM rlike_ex WHERE REGEXP_LIKE(city, 'san.*', 'i');
+---------------+
| CITY |
|---------------|
| San Francisco |
| San Jose |
+---------------+