import re phonePattern = re.compile(r'^\D*(\d{3})\D*(\d{3})\D*(\d{4})\D*(\d*)$') print phonePattern.search('(000)8881234 ext. 1234').groups() print phonePattern.search('000-888-1234').groups() print phonePattern.search('work 1-(000) 888.1234 #1234')