fork download
  1. import re
  2.  
  3. s = 'AB+B+" HELLO"+TODAY()/C* 100'
  4. rs = re.sub(r'"[^"]*"|\bTODAY\b|\b([A-Z]+)\b',
  5. lambda m: 'a2num("' + m.group(1) + '")' if m.group(1) else m.group(), s)
  6.  
  7. print (rs)
Success #stdin #stdout 0.01s 7296KB
stdin
Standard input is empty
stdout
a2num("AB")+a2num("B")+" HELLO"+TODAY()/a2num("C")* 100