How can i get rid of these u
in output?
Regex:
Tregex1 = "1?\W*([2-9][0-8][0-9])\W*([2-9][0-9]{2})\W*([0-9]{4})(\se?x?t?(\d*))?"
Code:
for a in re.findall(Tregex1,text_value,re.IGNORECASE):
print a
Output:
(u'877', u'638', u'7848', u'\n', u'')
(u'650', u'627', u'1000', u'\n', u'')
(u'650', u'627', u'1001', u'\nE', u'')
(u'312', u'273', u'4100', u'', u'')
I tried using these & followed several similar links
a.encode('ascii', 'ignore')
a.encode('utf-8')
",".join(a)
But none of them are working.
Expected Output:
877-638-7848
650-627-1000
650-627-1001
312-273-4100
I am using Python 2.7
Also can someone explain, why i am getting sometimes \n while \nE otherwise or even blank?