Skip to content

Instantly share code, notes, and snippets.

@morrismukiri
Last active November 2, 2026 18:03
Show Gist options
  • Select an option

  • Save morrismukiri/920494322a47d9485bbc to your computer and use it in GitHub Desktop.

Select an option

Save morrismukiri/920494322a47d9485bbc to your computer and use it in GitHub Desktop.
Kenyan phone number regular expression
@Steven-zion

Copy link
Copy Markdown

the phone input am using holds the phone to state in the format +254 712 345678, it has refused to pass most regex. can it be the spacing. please provide me with a regex that validates this exactly as it is, thanks

@LukeNgirubiu

LukeNgirubiu commented May 4, 2024 via email

Copy link
Copy Markdown

@obbyK

obbyK commented Jun 14, 2024

Copy link
Copy Markdown

Works with Java, but you can probably simplify them further.

Safaricom (\\+?254|0)?([7][0129][0-9]|[7][4][0123568]|[7][5][789]|[7][6][89]|[1][1][012345]){1}[0-9]{6}
Airtel (\\+?254|0)?([7][38][0-9]|[7][5][0123456]|[7][6][2]|[1][0][012345678]){1}[0-9]{6}
Telkom (\\+?254|0)?(77[0-9]){1}[0-9]{6}
Faiba (\\+?254|0)?(747){1}[0-9]{6}
Equitel (\\+?254|0)?(76[3456]){1}[0-9]{6}

@Bradleykingz

Copy link
Copy Markdown

(+?2547\d{8}|07\d{8}|+?25411\d{7}|011\d{7})

@iamsarahthomas92-rgb

Copy link
Copy Markdown

Students often face difficulties when managing multiple university assignments, especially when topics require detailed research and careful preparation. Finding the right academic resources can make the learning process more manageable and help students understand complex requirements. Before choosing any academic support option, it is important to consider quality, transparency, and academic integrity. Those researching buy an assignment services should look for responsible guidance that supports their understanding and learning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment