Regular Expressions 101

Community Patterns

https://regex101.com/r/edPG4P/1

0

Regular Expression
Python

r"
(\d{3}-)?\d{3}-\d{4}(,)?
"
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