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