I am trying to convert a Java regex to a Flutter(Dart) regex but I am having trouble.
My Java Code and Regex example, witch returns Matching:
public static void main(String[] args) {
String EMAIL_VALIDATION_REGEX = "^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$";
String email = "[email protected]";
if(!Pattern.matches(EMAIL_VALIDATION_REGEX, email)) {
System.out.println("Not matching!");
}else {
System.out.println("Matching!");
}
}
My Flutter Code example witch returns Not Matching:
final RegExp _emailRegex = RegExp(
r"^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$",
caseSensitive: false,
multiLine: false);
final String _email = "[email protected]";
if (!_emailRegex.hasMatch(_email)) {
print("Not Matching!");
} else {
print("Matching!");
}
I have basically copied the regex that i use in java and added r as a prefix. Can someone help me identify the issue with this code?