For explanatory purposes I have marked parts of a string with different backgrounds.

But this string is part of some Mathematica expression, which processed. My program worked fine before I added the explanatory highlighting. It does not work any longer after my highlighting.

Now I look for some procedure, which removes all Background outline from a Mathematica string in order to be able to use my example without removing any highlighting it might contain. A Shift-Ctl-Space would be unsportsmanlike, of course, because the explanation is, after all, helpful for understanding.


"String mit einem \!\(\*StyleBox[\"markierten\",Background->RGBColor[1, 1, 0.85]]\) Wort."

shall become (regardless of the color of the Background)

"String mit einem markierten Wort."

1 Answer 1

str1 = "String mit einem \!\(\*StyleBox[\"markierten\",Background->RGBColor[1, 1, 0.85]]\) Wort.";

str2 = ExportString[str1, "Text"]

(* returns "String mit einem markierten Wort." *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.