webCOMAND

#REGEXMATCH

Returns TRUE if the subject string matches the regular expression, otherwise FALSE.

Prototype

#REGEXMATCH($regex, $subject)

Parameters

  • regex - A PCRE pattern to match on.  It can be a variable or string containing the PCRE, including the leading and trailing delimiter and optional modifier or a bare PCRE with a leading and trailing delimiter and optional modifier.
  • subject - The input string to match against.

Return

Returns TRUE if the subject matches regex, otherwise FALSE.

Example

#ASSIGN($Text, 'Test')

#* bare regex *#
#IF(#REGEXMATCH(/^tes/i, $Text))
Starts with 'tes' (case insensitive match).
#ENDIF

#* string regex *#
#IF(#REGEXMATCH('/st$/', $Text))
Ends with 'st' (case sensitive match).
#ENDIF

#* variable regex *#
#ASSIGN($RegEx, '/ES/i')
#IF(#REGEXMATCH($RegEx, $Text))
Contains 'ES' (case insensitive match).
#ENDIF

Related

#REGEXREPLACE, #REGEXSELECT