Community Patterns

Community Library Entry

-2

Regular Expression
Created·2016-07-19 04:29
Flavor·Python

r"
(?:(\+?\d{1,3}) )?(?:([\(]?\d+[\)]?)[ -])?(\d{1,5}[\- ]?\d{1,5})
"
Open regex in editor

Description

An extremely complete regex, that...

  • Accepts international phones and most of regional phone numbers;
  • Accepts phone numbers with/without "+", with/without space or "-" in the middle of the phone, and more.
  • Gets groups of all important data of the phone number (local code, country code and the phone number itself)
Submitted by @thegamerbr1