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}$)';
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}$)';
4
Answers
Use this regex pattern –
String pattern = r'([0][6,7]d{8})
this regex should work for you:
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 matcherd
).find out more about this regex here: regex101
or you can apply keyboardtype property to
textfield
ortextformfield
if you are not familiar withregExp
You can match a zero, then either 6 or 7 using character class followed by 8 digits.
For a match only, you can omit the capture group.