matches function

bool matches(
  1. String str,
  2. Pattern pattern
)

Checks if the string matches the given pattern.

The pattern may be a RegExp or any Pattern. A match anywhere in the string is sufficient.

Example:

matches('abc123', RegExp(r'\d+')); // true
matches('abc', RegExp(r'^\d+$')); // false

Implementation

bool matches(String str, Pattern pattern) => _matches(str, pattern);