I have a regex that i'm trying to match the phone number. However, 1 of the scenario of phone numbers have blanks/whites paces in the front and it's causing groups() error because of NoneType
How do I avoid this?
s = ' 1234567890'
pattern = re.compile(r'''^(?:\s*\(?)(\d{3})\)*[-\. ]*(\d{3})[-. ]?(\d{4})\s+$''',re.VERBOSE)
match = pattern.match(s)
match.groups()
AttributeError: 'NoneType' object has no attribute 'groups'