I have byteslike 'foo\x20\x20\x08\x08bar'
I need have the backspaces ('\x08') evaluated when and only when they are lead by identical number of spaces ('\x20').
x = re.sub('\x20+\x08+', '', t) is the naive way of doing this, but fails to produce correct output when t = 'foo\x20\x20\x08'
Is there a way to define a regular expression that takes the length of a previous group in to account when matching the second group or do I need do this manually with re.finditer & re.span() and then manually re-checking the preceding blocks?