Community Patterns

Community Library Entry

1

Regular Expression
Created·2015-07-25 18:34
Flavor·PCRE (Legacy)

/
(?=^(?:\+|00)?(?:[\-\/\(\)]?\d){11}$)(?:00|\+)[^\d]*([\d])[^\d]*([\d])[^\d]*([\d])[^\d]*([\d])[^\d]*([\d])[^\d]*([\d])[^\d]*([\d])[^\d]*([\d])[^\d]*([\d])[^\d]*([\d])[^\d]*([\d])$
/
gm
Open regex in editor

Description

Let's say a phone number is valid in case it has 11 digits (or 13 in case we use 00 instead of + ). Take those lines to common format. original idea was to remove all non-digit characters from those lines with simple match like [^\d] but combined with look-ahead it just did not work, had to go through each digits to capture and put back. Looking forward to any prettier solution.

Submitted by zolo