I'm trying to escape the strings in this sequence
[0m[ERROR] [1585551547.349979]: Failed to create bragfiles/downtimer/fight100/2020-03-27. Error: 550 Create directory operation failed.
[ERROR] [1585551547.349979]: Failed to create bragfiles/downtimer/fight100/2020-03-27. Error: 550 Create directory operation failed.
and
[32m[INFO] [2020-03-29 23:58:50.607198] TaskManager.poll: system has no current task.[0m
[INFO] [2020-03-29 23:58:50.607198] TaskManager.poll: system has no current task.
Plus the occasional double symbol
"[0m[32m[INFO] [2020-03-29 23:58:34.695268] Polling for updates from the server for fight100...[0m"
"[INFO] [2020-03-29 23:58:34.695268] Polling for updates from the server for fight100..."
I've come across this before but it doesn't seem to be correct in my case:
- How can I remove the ANSI escape sequences from a string in python
- Remove all ANSI colors/styles from strings
I've been trying various variations of \x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]) but I don't think that fits the bill
But none of the regexes I've tried so far seem to be generic enough
[0mand[32m?text = text.replace('[0m','').replace('[32m','')?'[TEXT]sequence? Can the string be reliably split so the color escape sequence will be at the start of the resultant strings? Is the color sequence either at the start of the string OR preceded by a period? Have you considered making multiple passes?