Community Patterns

Community Library Entry

1

Regular Expression
Created·2025-12-19 21:17
Flavor·PCRE2 (PHP)

/
^\+?(\d+)?[ \.-]*\(?(\d{3}){1}\)?[ \.-]*(\d{3}){1}[ \.-]*(\d{4}){1}(?:[ ,]*)(?:e?x[tension\.: #]+|opt[ion:\. ]+|#)?(\d+[ ,#]*)?$
/
gmi
Open regex in editor

Description

Search string for use in contact cleaning project $1 = intenational code, omitting preceding "+" $2 = area code $3 = first three digits of phone number $4 = last four digits of phone $5 = extension, inclusive of any commas or hashes to automate phone tree navigation TO DO handle recursive menus (e.g., "321-321-1234,,,1234#,,123344#....)

Submitted by Jason