Regular Expression In Python For E-Mail And Phone Number
Join the DZone community and get the full member experience.
Join For Free// code contains regular expression for contact number and email address in python
str='abc@example.com'
match=re.search(r'\w+@\w+',str) #return abc@example.com
num=555-555-555
match_num=re.search(r'^(\d{3}--\d{3}--\d{4})$',num) #return 555-555-5555
Python (language)
Opinions expressed by DZone contributors are their own.
Comments