The phone number should start with 0 followed by 6 or 7 and should contain 10 digits only
Here are some sample phone numbers
0754758644 ,0621165600
Here is what I tried
String pattern = r'(^(?:[0]9)?[0-9]{10,12}$)';
CodePudding user response:
this regex should work for you:
String pattern = r'(^0(6|7)\d{8}$)'
I limited the digits to 8, because the 0 and the 6/7 already take up two digits of the length. The {8}
only limits the direct predecessor (the digits matcher \d
).
find out more about this regex here: regex101
CodePudding user response:
Use this regex pattern -
String pattern = r'([0][6,7]\d{8})
CodePudding user response:
String pattern = r'^(?:[ 0][1-9])?[0-9]{10,12}$';
RegExp regExp = new RegExp(patttern);
regExp.hasMatch(value)
or you can apply keyboardtype property to textfield
or textformfield
if you are not familiar with regExp