REGEXP_LIKE (Lakehouse v1)
REGEXP_LIKE function is used to check that whether the string matches the regular expression.
Analyze Syntax
Section titled “Analyze Syntax”func.regexp_like(<expr>, <pat[, match_type]>)Analyze Examples
Section titled “Analyze Examples”func.regexp_like('a', '^[a-d]')┌─────────────────────────────────┐│ func.regexp_like('a', '^[a-d]') │├─────────────────────────────────┤│ 1 │└─────────────────────────────────┘SQL Syntax
Section titled “SQL Syntax”REGEXP_LIKE(<expr>, <pat[, match_type]>)Arguments
Section titled “Arguments”| Arguments | Description |
|---|---|
<expr> | The string expr that to be matched |
<pat> | The regular expression |
[match_type] | Optional. match_type argument is a string that specifying how to perform matching |
match_type may contain any or all the following characters:
c: Case-sensitive matching.i: Case-insensitive matching.m: Multiple-line mode. Recognize line terminators within the string. The default behavior is to match line terminators only at the start and end of the string expression.n: The.character matches line terminators. The default is for.matching to stop at the end of a line.u: Unix-only line endings. Not be supported now.
Return Type
Section titled “Return Type”BIGINT
Returns 1 if the string expr matches the regular expression specified by the pattern pat, 0 otherwise. If expr or pat is NULL, the return value is NULL.
SQL Examples
Section titled “SQL Examples”SELECT REGEXP_LIKE('a', '^[a-d]');┌────────────────────────────┐│ REGEXP_LIKE('a', '^[a-d]') │├────────────────────────────┤│ 1 │└────────────────────────────┘
SELECT REGEXP_LIKE('abc', 'ABC');┌───────────────────────────┐│ REGEXP_LIKE('abc', 'ABC') │├───────────────────────────┤│ 1 │└───────────────────────────┘
SELECT REGEXP_LIKE('abc', 'ABC', 'c');┌────────────────────────────────┐│ REGEXP_LIKE('abc', 'ABC', 'c') │├────────────────────────────────┤│ 0 │└────────────────────────────────┘
SELECT REGEXP_LIKE('new*\n*line', 'new\\*.\\*line');
┌───────────────────────────────────────────┐│ REGEXP_LIKE('new*\n*line', 'new\*.\*line')│├───────────────────────────────────────────┤│ 0 │└───────────────────────────────────────────┘
SELECT REGEXP_LIKE('new*\n*line', 'new\\*.\\*line', 'n');
┌────────────────────────────────────────────────┐│ REGEXP_LIKE('new*\n*line', 'new\*.\*line', 'n')│├────────────────────────────────────────────────┤│ 1 │└────────────────────────────────────────────────┘