Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression for Pakistan's mobile number [closed]

Tags:

regex

I want a regular expression for mobile number start with '+92' or '0' and user will type onlye ten digits more.

like image 730
Adi Khan Avatar asked Jun 07 '14 20:06

Adi Khan


Video Answer


1 Answers

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!

like image 92
Giacomo1968 Avatar answered Oct 20 '22 22:10

Giacomo1968