Skip to main content

matches

Checks whether a given regex pattern matches entirely with the search string.

matches(searchString, regex)

Parameters#

  • searchString: The string to search within
  • regex: The regular expression pattern to match with searchString

Returns#

  • A boolean true only if the regex matches with the entire string and not a part of it.

Examples#

assertTrue(matches('Your account is locked, call us at 10902 55555 for your options.',    '(?i)[a-z\\s]+account[a-z\\s]+locked[a-z\\s\\S]+\\d{5}\\s\\d[5][a-z\\s\\S]+'))
info

Read our notes on regular expression to learn about the regex pattern rules.