In this post, we will solve Split the Phone Numbers HackerRank Solution. This problem (Split the Phone Numbers) is a part of HackerRank Regex series.
Solution – Split the Phone Numbers – HackerRank Solution
Python
import re p = re.compile('(\d{1,3})[-|\s](\d{1,3})[-|\s](\d{4,10})') n = int(input()) for i in range(n): x = str(input()) if(len(re.findall(p, x)) > 0): y = re.findall(p, x)[0] print("CountryCode="+y[0]+",LocalAreaCode="+y[1]+",Number="+y[2])
Note: This problem (Split the Phone Numbers) is generated by HackerRank but the solution is provided by CodingBroz. This tutorial is only for Educational and Learning purpose.