Jump to content

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


Mubashshsir Hasan

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 an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...