Regex Error Finding Details from a bank statement

  python-3.x, re

I am working with Regex and currently I am trying to extract the Name, IFSC and Account No. from the PDF.
I am using following code to extract the details.

acc_name= " ", 'n'.join([re.sub(r'^[d t]+|[d t]+:$', '', line) for line in data.splitlines() if 'Mr. ' in line])
acc_no= " ", 'n'.join([re.sub(r'Account Numbers+:', '', line) for line in data.splitlines() if 'Account Number' in line])
acc_code = " ", 'n'.join([re.sub(r'IFSC Codes+:', '', line) for line in data.splitlines() if 'IFSC Code' in line])

But the data which I am getting back is following:

(' ', ' 50439602642')
(' ', 'Mr. MOHD AZFAR ALAM LARI')
(' ', ' ALLA0211993')

I want to remove the commas, brackets and quotes. I am new with regex so any help would be appreciated.

Source: Python-3x Questions

LEAVE A COMMENT