Skip to content

Instantly share code, notes, and snippets.

@rohankhudedev
Created February 7, 2017 06:16
Show Gist options
  • Save rohankhudedev/f474cfd65254cfe944a246e8a22cd665 to your computer and use it in GitHub Desktop.
Save rohankhudedev/f474cfd65254cfe944a246e8a22cd665 to your computer and use it in GitHub Desktop.
regex for global to identify pattern for common phone number
i used regex which support varitey of global phone numbers
/^\s*(?:\+?(\d{1,3}))?([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$/gm
Positive -
+42 555.123.4567
+1-(800)-123-4567
+7 555 1234567
+7(926)1234567
(926) 1234567
+79261234567
926 1234567
9261234567
1234567
123-4567
123-89-01
495 1234567
469 123 45 67
89261234567
8 (926) 1234567
926.123.4567
415-555-1234
650-555-2345
(416)555-3456
202 555 4567
4035555678
1 416 555 9292
Negative:
926 3 4
8 800 600-APPLE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment