validate method

bool validate(
  1. String 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(String pattern) {
  final String? _copy = this;
  if (_copy == null) {
    return false;
  }
  return RegexUtils.check(_copy, pattern);
}