check if string matches the pattern.
bool matches(String str, pattern) { RegExp re = RegExp(pattern); return re.hasMatch(str); }