Conditions.bool-primary-like-regex
Returns True if a value matches a regular expression
Format
expression [ NOT ] LIKE_REGEX Pattern [FLAG Options]
Remarks
Checks if a string value matches a given regular expression.
Pattern is a regular expression pattern. For more information on regular expression patterns, refer to Regular Expressions.
If specified, the Options argument changes the pattern matching behaviour. For more information on regular expression options refer to Regular Expression Option Flags
The LIKE_REGEX predicate returns Unknown if any of the operands are NULL.
Example 1: Find all badly formed UK postal codes (assumes CDBObject has a custom field called Postcode).
SELECT FullName FROM CDBObject WHERE Postcode NOT LIKE_REGEX '[[:alpha:]]{1,2}[[:digit:]]{1,2}[[:alpha:]]? [[:digit:]][[:alpha:]]{1,2}' FLAG 'i'
Example 2: Find all well formed US ZIP codes (assumes CDBObject has a custom field called Zipcode).
SELECT FullName FROM CDBObject WHERE Zipcode LIKE_REGEX '[[:digit:]]{5}(-[[:digit:]]{4})?'