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