fork download
  1. import re
  2. rx = r'=[^\d-]*(?P<mean>-?\d*\.?\d+)\s*\+/-\s*(?P<sd>\d*\.?\d+)\W+(?P<units>.+)'
  3. text = r"ΔG'° = (-19.9 +/- 0.4) kilojoule / mole"
  4. m = re.search(rx, text)
  5. if m:
  6. print(m.groupdict())
Success #stdin #stdout 0.02s 9500KB
stdin
Standard input is empty
stdout
{'mean': '-19.9', 'sd': '0.4', 'units': 'kilojoule / mole'}