0

I have a problem with the regular expression to look for a substring within a string.

void main(){

  var string = "HOLA MUNDO";

  RegExp exp = new RegExp(r'/MUNDO/',caseSensitive: false,);
  exp.hasMatch(string)==true? print('Match'): print('nope');


}

1 Answer 1

1

I don't believe the / at the front of the RegExp works in Dart (or, at least not the way you may have intended). Try RegExp exp = new RegExp(r"MUNDO", caseSensitive: false);. Your regex is failing because it tries to match a literal '/' in the string.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.