Remove escape characters from string

Hello all,
I have a string var which contains formatting characters at the end, it is a string with EScape sequences at the end of it.
How can I remove them so that I only keep the 'real' text?
I tried :
var1=${var1%%\033[0m}
does not seem to do the job ....
Please help
Thanks

Pattern match it:

grep "$[ \t\r\n]" $var

Eh, something like that. But basically that's the pattern you want to match $ on the pattern indicating that it's the end of the string.

most modern sed implemenations support POSIX character classes
[:cntrl:] is one those

echo ""$var" | sed 's/[:cntrl:]\[0m$//'

except this gets only the one escape sequence you gave in your example.