Given the following string:
"foo\e[38;5;1mbar\e[0mbaz"
How can I remove both \e[38;5;19m
and \e[0m
with sed without knowing the exact values of the numbers within those strings?
Expected output:
foobarbaz
I have the following sed line, which matches the first string:
# regex: \\e\[[^/]*m
sed -E 's/\\e\[[^/]*m//g'
This returns sed: 1: unbalanced brackets ([])
.
How can I get rid of both strings where the numbers are not known?