Last active
December 31, 2018 10:41
-
-
Save Anyoks/5a358993479b5d4932bbba2bac348fe8 to your computer and use it in GitHub Desktop.
Matching Kenyan Phone Numbers with a reular expression.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To match 07xx xxx xxx number | |
/^0(7(?:(?:[129][0-9])|(?:0[0-8])|(4[0-1]))[0-9]{6})$/ | |
To match +254 7xx xxx xxx | |
/^(?:+254)?(7(?:(?:[129][0-9])|(?:0[0-8])|(4[0-1]))[0-9]{6})$/ | |
To match 254 7xx xxx xxx | |
/^(?:254)?(7(?:(?:[129][0-9])|(?:0[0-8])|(4[0-1]))[0-9]{6})$/ | |
To match all the different number formats | |
/^(?:254|\+254|0)?(7(?:(?:[129][0-9])|(?:0[0-8])|(4[0-1]))[0-9]{6})$/ | |
https://rubular.com/ to test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment