I am wondering if there is a better Python Regex solution for the one that I currently have? Currently my code is:
import re
n = '+17021234567'
m = '7021234567'
match = re.search(r'(?:\+1)?(\d{10})', n)
match.group(1)
match = re.search(r'(?:\+1)?(\d{10})', m)
match.group(1)
The goal of the code is to only extract the 10 digit ph # if it has a leading +1 or not. Currently it works, but I am wondering is there a way to just call match.group() to get the 10 digit ph # without calling match.group(1)?