matchesEntirely method
Check whether the entire input sequence can be
matched against the regular expression.
regex
is the regular expression to match against.
str
is the string to test.
returns true if str can be matched entirely against regex.
Implementation
bool matchesEntirely(Pattern regex, String str) {
RegExp pattern = (regex is String) ? RegExp(regex) : regex as RegExp;
Match? match = pattern.firstMatch(str);
if (match == null) return false;
return match.group(0) == str;
}