fork download
  1. import re
  2. regex = re.compile(r'(?:\((\d{3})\)\s*|(\d{3})-?)')
  3. print(filter(None, regex.match('(123) ').groups()))
Success #stdin #stdout 0.02s 6996KB
stdin
Standard input is empty
stdout
('123',)