May-25-2017, 02:57 AM
i would like to do a split on a string (including bytes) such that it splits control characters as classes. for example if a string is
'foo\nbar'
the split result would be ['foo',\n','bar']
. note that i want to keep the splitting character. but 2 or more of the same splitting character should be left together so b'\x00\x01\x01\x02'
would result in [b'\x00',b'\x01\x01',b'\x02']
. any ideas?