fork download
  1. import re
  2. expression = "($mat.name == 'sign') AND ($most == 100.0)"
  3. tokens = re.findall(r"\$*(?:[a-z]*\.)?[a-z]+|not|[+/*()-]|\d*\.\d+|[\d=]+", expression, re.I)
  4.  
  5. print tokens
Success #stdin #stdout 0.02s 6996KB
stdin
Standard input is empty
stdout
['(', '$mat.name', '==', 'sign', ')', 'AND', '(', '$most', '==', '100.0', ')']