I need to get the following string as if it were printed using print()
str = '1234\b\b\b\b\r5678\n'
I want to apply the backspace characters ('\b','\r' and etc), for an output (str2) line of the form:
str2 = '5678\n'
And another example:
str = '1234\b\r5678\nqwert\b\b\b\b\b\b\b\b\r1234'
Result:
str = '5678\n1234'