I have multiple strings like :
a = 'avg yearly income 25,07,708.33 '
b = 'current balance 1,25,000.00 in cash\n'
c = 'target savings 50,00,000.00 within next five years 1,000,000.00 '
I'm trying to split them into chunks of strings of texts and strings of numbers with sample output like :
aa = [('avg yearly income', '25,07,708.33')]
bb = [('current balance', '1,25,000.00', 'in cash')]
cc = [('target savings', '50,00,000.00', 'within next five years', '1,000,000.00')]
I'm using the following code :
import re
b = b.replace("\n","")
aa = re.findall(r'(.*)\s+(\d+(?:,\d+)*(?:\.\d){1,2})', a)
bb = re.findall(r'(.*)\s+(\d+(?:,\d+)*(?:\.\d){1,2})(.*)\s+', b)
cc = re.findall(r'(.*)\s+(\d+(?:,\d+)*(?:\.\d){1,2})(.*)\s+(\d+(?:,\d+)*(?:\.\d{1,2})?)', c)
I'm getting following output :
aa = [('avg yearly income', '25,07,708.3')]
bb = [('current balance', '1,25,000.0', '0 in')]
cc = [('target savings', '50,00,000.0', '0 within next five years', '1,000,000.00')]
What's wrong with the pattern of regular expressions?