I have created this working regex below, this aims to accept phone numbers only ex. 09338195838.
^(09)[0-9]{9}
However I don't know how to set a maxlength that will accept only 11 digits. I've been to other similar questions like q1 but none really helped, and tried the below code but still it accepts even if it exceeds to 11 digits.
((09)[0-9]{9}){11}
Here is the detailed structure:
09Someone knows how to do this?
^09[0-9]{9}$
The $ symbol means "The string has to end, without other characters after this".
You can set word boundry.
((09)[0-9]{9})\b
test: https://regexr.com/51c40
if you want to make it more elastic, not only 11 digit
you can use ((09)\d{0,9})\b
{0,9} sets the min and max lengths, now it accepts maximum 11 digits starts with 09 and min 2 digits that is 09.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With