Automate

Automate

Make your phone or tablet smarter with automation

Get it on Google Play

matches

array matches(value, regex)

Returns the result of matching a value against a regular expression.

An array value will return the result of the first matching element, a dictionary value will return the result of the first matching entry key, otherwise the text of value itself is matched.

This function will only find a single, the first match, use the findAll function to find all matching parts. Unlike findAll, the whole regex must match, for a partial match use .*, e.g. .*foo.*.

Both the regular expression syntax and text literals use the backslash \ and left curly bracket { characters for special purpose. Use \\ and \{ to avoid the text literal interpretation.

Flags embedded as a prefix in regex:

FlagDescription
(?d)Unix lines mode
(?i)Case-insensitive matching (US-ASCII only)
(?iu)Case-insensitive matching (Unicode, preferred)
(?m)Multiline mode
(?s)Dotall mode, use it when matching a multiple line value
(?u)Unicode-aware case folding
(?x)Ignore whitespace and comments in pattern

Parameters

  1. value — value to be matched.
  2. regexregular expression to match against.

Returns

  • an array containing the entire matched result and any capture groups, or null if there were no match.
Note! This documentation is also accessible within the app from Help & feedback menu.