As an exercise I was trying to come up with a regex to evaluate simple algebra like
q = \'23 * 345 - 123+65\'
From here I want to get \'23\', \
Your regex is confusing. Better to use re.split() for this purpose:
re.split()
q = '23 * 345 - 123+65' print re.split('\s*([-+/*])\s*', q)
Outputs:
['23', '*', '345', '-', '123', '+', '65']