Skip to content

Instantly share code, notes, and snippets.

@muiton
Forked from maguay/phone_extract.txt
Created March 13, 2019 02:27
Show Gist options
  • Save muiton/1bbfc2e6b2e83d3eac329baf7354e499 to your computer and use it in GitHub Desktop.
Save muiton/1bbfc2e6b2e83d3eac329baf7354e499 to your computer and use it in GitHub Desktop.
Regex to find phone phone numbers in all standard and international formats
(?:(?:\+?([1-9]|[0-9][0-9]|[0-9][0-9][0-9])\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([0-9][1-9]|[0-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?
/a tweaked version of the second regex in the question here to allow for all country codes and leading zeros in area codes: https://stackoverflow.com/questions/3868753/find-phone-numbers-in-python-script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment