REGEXP_MATCHES() returns true when a regular expression matches anywhere in a string, and false when it does not. Use it to filter or flag rows by the shape of a value: invoice numbers that start with a prefix, names that contain a digit, phone numbers that begin with a country code. To test the whole value against a pattern, use REGEXP_FULL_MATCH().
REGEXP_MATCHES(string, pattern [, options]) REGEXP_MATCHES() returns a boolean value
// A match anywhere in the string
REGEXP_MATCHES('abc123', '[0-9]+') = true
REGEXP_MATCHES('abc', '[0-9]') = false
// ^ ties the match to the start, $ to the end
REGEXP_MATCHES('abc123', '^[a-z]+') = true
REGEXP_MATCHES('abc123', '^[0-9]+') = false
REGEXP_MATCHES('abc123', '[0-9]+$') = true
// Ignoring case: (?i) in the pattern, or the option 'i'
REGEXP_MATCHES('ABC', '(?i)abc') = true
REGEXP_MATCHES('ABC', 'abc', 'i') = true
REGEXP_MATCHES('ABC', 'abc', 'c') = false
^ and end it with $ to tie it to the start and the end, or use REGEXP_FULL_MATCH().(?i) at the start of the pattern ignores case, and so does 'i' as the third argument. The other option letter in everyday use is 's', which lets a dot match a line break.\d, \w and \s stand for a digit, a letter, digit or underscore, and a blank, of the unaccented alphabet. An accented letter counts as one character, but not as a \w.