I want a regular expression for mobile number start with '+92' or '0' and user will type onlye ten digits more.
Did you even do a basic Google search for “regex for pakistan mobile”? Here a solution from the first result:
^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$
UPDATE: As per a July 23, 2021 comment left by fWd82 an improved regex can be found here:
^((\+92)?(0092)?(92)?(0)?)(3)([0-9]{9})$/gm
According to fWd82:
“But above regex validate these as well which aren't valid numbers:
+924001234567
30012345673
00924001234567
Also these are valid numbers but it rejects it:923001234567
3001234567
”
Made this edit since the question is closed, but this new info is very useful and comments are often overlooked. Nice work fWd82!
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