import re text = input('Enter your text with phone number using xx-xxxxxxx format \n') contact = re.compile(r'\d\d-\d\d\d\d\d\d\d') for i in range(len(text)): chunk = text[i:i+10] mo = contact.search(chunk) if mo: print('Phone Number Found:'+mo.group()) Thanks ************************ Aadesh Shrestha