Given this string "foo-bar=369,337,234,123"
, I'm able to parse it to ['foo-bar', '369', '337', '234', '123]
with this regular expression:
re.findall(r'[a-zA-Z0-9\-_\+;]+', 'foo-bar=369,337,234,123')
Now, if I escape some of the ,
in the string, e.g. "foo-bar=369\,337\,234,123"
, I would like it to be parsed a bit differently: ['foo-bar', '369\,337\,234', '123']
. I tried the below regex but it doesn't work:
r'[a-zA-Z0-9\-_\+;(\\,)]+'
basically trying to add the sequence of characters \,
to the list of characters to match.