fork download
  1. import re
  2. strings = [r'foo-bar=369,337,234,123', r'foo-bar=369\,337\,234,123']
  3. rx = re.compile(r"[\w+;-]+(?:\\,[\w+;-]+)*", re.A)
  4. for s in strings:
  5. print(f"Parsing {s}")
  6. print(rx.findall(s))
Success #stdin #stdout 0.02s 9504KB
stdin
Standard input is empty
stdout
Parsing foo-bar=369,337,234,123
['foo-bar', '369', '337', '234', '123']
Parsing foo-bar=369\,337\,234,123
['foo-bar', '369\\,337\\,234', '123']