webCOMAND

#REGEXSELECT

Return a string or array of strings that match a regular expression pattern within a subject string.

Prototype

#REGEXSELECT($pattern, $subject, $index = NULL)

Parameters

  • pattern - 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.
  • index - Optional zero-based index of the match to return.  An array of all matches is returned if not specified.

Return

If an index is specified, return the corresponding match or NULL if no corresponding match is found.  If an index is not specified, return an array of zero or more matches.

Example

#ASSIGN($Text, 'Testing')

#/ will return 'ing'
#REGEXSELECT(/(t.*t)(.*)$/i, $Text, 1)

Related

#REGEXMATCH, #REGEXREPLACE