validate method

bool validate (
  1. Pattern pattern
)

Returns whether the regular expression pattern has a match in this string.

For some pre-defined regular expressions, check out RegexUtils

Example usage

final String greetings = "Hello World";

if (greetings.validate(RegexUtils.name)) {
  return "Hello Mr $greetings";
} else {
  return "$greetings is not a name";
}

Implementation

bool validate(Pattern pattern) {
  return RegexUtils.check(this, pattern);
}