i am using jsch to get ssh output from a local ssh server.
When i display the output in a textbox i get all these weird string in the output for example:
]0;~/rails_sites/rex_raid
[32mRob@shinchanii [33m~/rails_sites/rex_raid[0m
I guess [33m and [0m mark the begin of a new color or something and ]0;~ marks a newline
how do i get rid of these withput parsing the output for those strings ?
Here a example (not from me) how my output looks like:
http://www.google.de/codesearch#048v6jEeHAU/typescript&q=%5D0;~&l=1
These are actually VT100 terminal control escape sequences. You can find a list of them (not sure if the list is complete) at http://www.termsys.demon.co.uk/vtansi.htm.
You can use the String’s replaceAll method (http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#replaceAll%28java.lang.String,%20java.lang.String%29), and create a regular expressions which matches all valid VT100 escape sequences. However when creating the regexp do not forget that there is non printable ESC char (that is \u001B in Unicode) before the square bracket.