Regular Expressions 101

Sp⁠onsors

Community Library

Community Library Entry

-2

Regular ExpressionOpen Workspace

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

Description
Created·2016-07-19 04:29
Type·Match
Flavor·Python

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
Open Workspace