Tabular IQ
Back to Function Index

REGEXP_FULL_MATCH()

Overview

REGEXP_FULL_MATCH() returns true when a regular expression matches a whole string, from its first character to its last, and false when it does not. Use it to check that a value has the format it should: a tax ID of two digits, a hyphen and seven digits, or an invoice number of a fixed shape. To test for a match anywhere in the value, use REGEXP_MATCHES().

Function Format

REGEXP_FULL_MATCH(string, pattern [, options])

Return Value

REGEXP_FULL_MATCH() returns a boolean value

Examples


// The whole string has to fit the pattern
REGEXP_FULL_MATCH('INV-00417', 'INV-[0-9]{5}') = true
REGEXP_FULL_MATCH('INV-00417x', 'INV-[0-9]{5}') = false

// A part that matches is not enough
REGEXP_FULL_MATCH('abc123', '[a-z]+') = false
REGEXP_FULL_MATCH('abc123', '[a-z]+[0-9]+') = true

// Any alternative that fits the whole string will do
REGEXP_FULL_MATCH('ab', 'a|ab') = true

// Ignoring case
REGEXP_FULL_MATCH('ABC', 'abc', 'i') = true

Notes

  • The result is the one REGEXP_MATCHES() gives for the same pattern with ^ before it and $ after it.
  • An empty pattern fits the empty string and no other.
  • Matching is case-sensitive. (?i) at the start of the pattern ignores case, and so does 'i' as the third argument. The option 's' 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.
  • A pattern that is not valid is refused, with the reason, when the formula is checked.
  • If the string or the pattern is null, the result is null.

See Also