Jump to content

In Python, how can I eliminate the ANSI escape sequences from a string


Recommended Posts

This is a snippet with my string in it.

'lsrnx1b[00mx1b[01;31mexamplefile.zipx1b[00mrnx1b[01;31m'

The string was produced from an SSH command I ran. I can't use the string as it is since it contains ANSI-standard escape sequences. How can I delete the escape sequences programmatically so that the only part of the text that remains is

'examplefile.zip'

Link to comment
Share on other sites

×
×
  • Create New...