match static method

bool match(
  1. dynamic value,
  2. dynamic regexp
)

Checks if string matches a regular expression

  • value a string value to match
  • regexp a regular expression string Returns true if the value matches regular expression and false otherwise.

Implementation

static bool match(dynamic value, dynamic regexp) {
  if (value == null && regexp == null) return true;
  if (value == null || regexp == null) return false;

  var str1 = StringConverter.toString2(value);
  var str2 = StringConverter.toString2(regexp);
  var reg = RegExp(str2);
  return reg.hasMatch(str1);
}