REGEXP_LIKE

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Returns true if the string matches the regular expression pattern.

Syntax 

1regexp_like(<string>, <pattern> [, flags])

Arguments 

Required 

  • <string>: The string to match against.
  • <pattern>: The regular expression pattern.

Optional 

  • flags: A string of option flags that modify matching behavior. Flags can be combined (for example, 'iq').

Flags 

FlagDescription
iCase-insensitive matching
cCase-sensitive matching (default)
qLiteral-string matching (disables regex metacharacters)

Returns 

Returns a boolean value indicating whether the string matches the pattern.

Considerations 

  • Equivalent to the ~ operator but in function form.
  • Matches anywhere within the string by default. Use ^ and $ anchors for full string matching.
  • Newline-sensitivity flags (n, m, s, p, w) aren’t supported.
  • For detailed regex syntax, see Regular Expression Syntax.

Examples 

Basic Match 

Check whether a string matches a pattern.

1SELECT regexp_like('hello world', 'world') AS result;

Returns true.

Match Digits 

Check whether a string contains digits.

1SELECT regexp_like('abc123', '\d+') AS result;

Returns true.

Full String Match 

Match the entire string using anchors.

1SELECT regexp_like('hello', '^hello$') AS result;

Returns true.

1SELECT regexp_like('hello world', '^hello$') AS result;

Returns false because the entire string does not match.

Case-Insensitive Matching 

Use the i flag for case-insensitive matching.

1SELECT regexp_like('HELLO WORLD', 'world', 'i') AS result;

Returns true.

Literal Pattern with q Flag 

Use the q flag to treat the pattern as a literal string, disabling regex metacharacters.

1SELECT regexp_like('a.b', 'a.b', 'q') AS result;

Returns true, matching the literal characters a.b rather than “any character between a and b.”

1SELECT regexp_like('axb', 'a.b', 'q') AS result;

Returns false.

Filter Rows 

Use in a WHERE clause to filter data.

1SELECT email FROM users
2WHERE regexp_like(email, '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$');

Returns rows with valid email format.

Related Documentation