Skip to content

Instantly share code, notes, and snippets.

@ahmedrowaihi
Created January 9, 2023 00:46
Show Gist options
  • Save ahmedrowaihi/4b5b0907dc7ae067d7122b434980771a to your computer and use it in GitHub Desktop.
Save ahmedrowaihi/4b5b0907dc7ae067d7122b434980771a to your computer and use it in GitHub Desktop.
A regex of saudi number pattern
/** A regex of saudi number pattern
* numbers will be accepted must match following formats:
* 9665xxxxxxxx, 009665xxxxxxxx, 05xxxxxxxx, +9665xxxxxxxx
* ^(\+966|966|00966|0)5 means that the number can start with +9665 or 9665 or 009665 or 05
* \d{8}$, means there should be 8 digits, and $ means the end of the string.
* All together: ^(\+966|966|00966|0)5\d{8}$
*/
const SaudiNumRegExp = /^(\+966|966|00966|0)5\d{8}$/;
export default SaudiNumRegExp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment