Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Python

r"
((\d{3}-)?\d{3}-\d{4}(,)?){3}
"
gm

Description

needs to be modified for use in python by this code example note use of {3 } and additional parenthesis around the

import re

nigeRegex = re.compile(r'((\d{3}-)?\d{3}-\d{4}(,)?){3}') nigeRegex.search('My numbers are 415-555-1234,555-4242,212-555-0000')

Submitted by anonymous - 5 years ago