Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9804 > unrolled thread

Re: Coloured strings

Started byAdriano Pascoletti <adriano.pascoletti@uniud.it>
First post2012-04-26 09:24 +0000
Last post2012-04-27 10:49 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Coloured strings Adriano Pascoletti <adriano.pascoletti@uniud.it> - 2012-04-26 09:24 +0000
    Re: Coloured strings David Bailey <dave@removedbailey.co.uk> - 2012-04-27 10:49 +0000

#9804 — Re: Coloured strings

FromAdriano Pascoletti <adriano.pascoletti@uniud.it>
Date2012-04-26 09:24 +0000
SubjectRe: Coloured strings
Message-ID<jnb48n$5ap$1@smc.vnet.net>
ToString[<coloured string>] removes colors
Adriano Pascoletti

2012/4/25 David Bailey <dave@removedbailey.co.uk>

> If you take an expression such as:
> "ABCDEFGHIJKLMNOPQRSTUVWXYZ"//FullForm
>
> and colour some portions of the string, you obtain:
>
> \!\(\*
> TagBox[
> StyleBox["\"\<\\!\\(\\*\\nStyleBox[\\(ABC\\*\\n StyleBox[\\\"DEF\\\",\
> \\nFontColor->RGBColor[1, 0, 0]]GHIJKLMN\\*\\n \
> StyleBox[\\\"OPQRSTUV\\\",\\nFontColor->RGBColor[0, 0, 1]]WXYZ\\)]\\)\
> \>\"",
> ShowSpecialCharacters->False,
> ShowStringCharacters->True,
> NumberMarks->True],
> FullForm]\)
>
> I am wondering if anyone knows an easy way to remove the colouring from
> such a string - other than creating a fairly complicated string pattern
> (bearing in mind that the original string might contain unpaired quotes,
> etc!)
>
> David Bailey
> http://www.dbaileyconsultancy.co.uk
>
>

[toc] | [next] | [standalone]


#9824

FromDavid Bailey <dave@removedbailey.co.uk>
Date2012-04-27 10:49 +0000
Message-ID<jndtk0$jje$1@smc.vnet.net>
In reply to#9804
On 26/04/2012 10:24, Adriano Pascoletti wrote:
> ToString[<coloured string>] removes colors
> Adriano Pascoletti
>
> 2012/4/25 David Bailey<dave@removedbailey.co.uk>
>
>> If you take an expression such as:
>> "ABCDEFGHIJKLMNOPQRSTUVWXYZ"//FullForm
>>
>> and colour some portions of the string, you obtain:
>>
>> \!\(\*
>> TagBox[
>> StyleBox["\"\<\\!\\(\\*\\nStyleBox[\\(ABC\\*\\n StyleBox[\\\"DEF\\\",\
>> \\nFontColor->RGBColor[1, 0, 0]]GHIJKLMN\\*\\n \
>> StyleBox[\\\"OPQRSTUV\\\",\\nFontColor->RGBColor[0, 0, 1]]WXYZ\\)]\\)\
>> \>\"",
>> ShowSpecialCharacters->False,
>> ShowStringCharacters->True,
>> NumberMarks->True],
>> FullForm]\)
>>
>> I am wondering if anyone knows an easy way to remove the colouring from
>> such a string - other than creating a fairly complicated string pattern
>> (bearing in mind that the original string might contain unpaired quotes,
>> etc!)
>>
>> David Bailey
>> http://www.dbaileyconsultancy.co.uk
>>
>>
Thanks,

what a simple and elegant solution! Somehow I would never have thought 
of feeding a string to ToString.

David Bailey
http://www.dbaileyconsultancy.co.uk

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web