Medium Beginners Problems > Ad-hoc
Dev Skill is working on a word processor program. One requirement of the task is to filter out some special pattern of words. For now the requirement is to filter out email address and mobile number from the text. Then challenging part of this task is, some clever person can type the email address and mobile number in a tricky way and this is in practice already. For example, someone can type his email address as hasan at gmail or someone can type his mobile number as 0 a 1 b 7 c 1 d 7 e 5 f 8 g 8 h 0 i 3 j 1. So our filtering process needs to make sure if a sequence fulfills the formats then it should be considered as an email address or mobile number. May be this can filter out some valid text which is not a mobile number or email address, but this consequence is accepted. For example, if the filtering process removes the following line: “Hello, I am Jalal and my password is 01717 and my ID card is 588-031. When shall I come for meeting?” In the above example, we shall make the filtered text as: “Hello, I am Jalal and my password is \*\*\*\*\* and my ID card is \*\*\*\-\*\*\*. When shall I come for meeting? Similar rule applies for email but with some exceptions, “@” and “at” is same, “.com” and “.kom” is also same. Please check the following rules for full set of replacement rules. **Rules:** **1)** Process text from left to right. That is, a match in left will have higher precedence. **2)** All matches should be case insensitive. **3)** Given a text, if we can find a sequence of 11 digits by removing zero or more character from the text such that the sequence starts with 017 or 018 or 019 or 011 or 015 or 016, then we must replace all the digits of the sequence with a star (‘\*’). For example, in following example text: “My mobile number is 0 a 1 b 7 c 1 d 7 e 5 f 8 g 8 h 0 i 3 j 1, please call me.” We can remove the characters (a,b,c,d,e,f,g,h,I,j) and we find a sequence 01717588031 which starts with 017 so we have to replace each digit with a star (‘*’) and the filtered text becomes: “My mobile number is * a * b * c * d * e * f * g * h * i * j *, please call me.” **4)** Given a text, we must replace all characters of “gmail”, “yahoo”, “hotmail”, “live”, “aol”, “facebook”, “rocketmail”, “zoho”, “ymail” with star (‘*’). For example, “Gmail” should be recplaced with “*****” (please disregard all quotation marks). **5)** Given a text, if we can find a sequence by removing zero or more space character from the text such that the sequence results “at” or “@” (without quotes), then we must replace up to 10 non space characters before the starting of “at” or “@” and also replace “@” and each letter of “at”. For example, in the following example: “My email address is something something A t gmaill.com. Please remove first something and extra l before dot and then email me, thanks.” We can remove the extra spaces and find “at” remove 10 non space character before it which results following filtered text: “My email address is somethin* ********* * * *****l.com. Please remove first something and extra l before dot and then email me, thanks.” Input: ------ Input starts with an integer **T (≤ 30)**, denoting the number of test cases. Each test case will have a text less than 500 character long, containing only ASCII printable characters. Each test case will be on its own line. That is, a new line character will indicate end of the text for one test case. Output: ------- For each test case, print the filtered text in its own line. Sample Input ------------ 3 88011 add 8303 add 9270. I am jalal at yahoo At Gmail I am @ KFC, come and meet me. Sample Output ------------- 88*** add **** add ****. * ** ***** ** ***** ** ***** * ** * KFC, come and meet me.