Skip to main content

REGEXP_LIKE

Checks if source string matches pattern and returns true or false.

See also:
[SELECT] [ Regular Expression Reference ]


Syntax

SELECT REGEXP_LIKE(source, pattern) FROM <multipartIdentifier>;

Arguments

source
A literal string or string column that you want to test for the existence of a pattern defined by a regular expression (pattern).

pattern
The regular expression pattern to search for.

Return Value(s)

Returns a 0 if false and 1 if true.


Examples

Determine if a string contains a pattern

select name, 
regexp_like(name, 'vm[0-9]+') as name_starts_with_vm
from azure.compute.virtual_machines
WHERE subscriptionId = '273769f6-545f-45b2-8ab8-2f14ec5768dc';

For more information, see https://github.com/nalgeon/sqlean/blob/main/docs/re.md