السلام عليكم ورحمة الله وبركاته ، هذا كود ريجيكس للتحقق من صحة أرقام الجوالات اليمنية ، يقوم الريجيكس بالتحقق من مفتاح الدولة ، مفتاح شركات الإتصالات والخطوط الارضية لضمان صحة النص المدخل .
yemeni phone number regex
Hello
this is a regex code to validate yemeni phone number for private companies and ground lines almost everything :) hope you found it useful.
/^(((\+|00)9677|0?7)[01378]\d{7}|((\+|00)967|0)[1-7]\d{6})$/
Example code in JavaScript:
/^(((\+|00)9677|0?7)[01378]\d{7}|((\+|00)967|0)[1-7]\d{6})$/.test('737198225')
according to wiki info here https://en.wikipedia.org/wiki/Telephone_numbers_in_Yemen
I've updated the regex to validate the strict format
Regex Explanition: Regex code splited to 2 parts due to their diffrent rules first part for private companies and the second for ground lines. so first for private copnies.
starting with:
((\+|00)9677|0?7)[01378]\d{7}
(\+|00)
match +
or 00
for global
9677
the 967
is countery key and the last 7
in 9677
is a prefix for all companies in yemen
all above or:
0?7
thats mean if it's locale call it may start with 07
or 7
then:
[01378]
yemeni compnies' code
0
for Y
1
for sabafon
3
for MTN
7
and 8
for yemen mobile
finally:
\d{7}
7 digits the customer number
all above was for praivte companies for ground lines:
((\+|00)967|0)[1-7]\d{6}
(\+|00)
match +
or 00
for global as before
967
is countery key as mentioned
all above or:
0
thats mean if it's locale call it may start with 0
then:
[1-7]
digits from 1 to 7
1
for sana'a
2
for Aden - Lahij - Abyan
3
Hodaidah
4
Ibb, Taiz
5
Hadramaut - Shabwah - Al Mahrah
6
Marib - Al Bayda - Al Jawf
7
Saddah - Hajjah - 'Amran - Al Mahwit
finally:
\d{6}
6 digits the customer number
hope it will help someone
any improvment is always welcomed.
Thanks alot