check if string str matches the pattern.
str
pattern
bool matches(String str, String pattern) => RegExp(pattern).hasMatch(str);