How can I colorize letters in the given string?
For instance:
string = "jaonvtaqhsy"
How to colorize 3 letters in the middle of string
(e,g, "vta")?
I tried:
Split the given string
in the three parts
a=StringTake[string, {1, 4}]
b=StringTake[string, {5, 7}]
c=StringTake[string, {8, 11}]
and then colorize each string
aa = Style[a, Blue, Bold]
bb = Style[b, Red, Bold]
cc = Style[c, Blue, Bold]
then join them back together
StringJoin[aa,bb,cc]
or
aa <> bb <> cc
but there is an error message
Row@{aa,bb,cc}
. Also, your string either needs to be 11 characters long, orc
should only take{8,10}
This will work for some applications, but may not be flexible depending on what you want to do. $\endgroup$aa
andbb
withHead
orTreeForm
and you will see they are notStrings
after you apply theStyle
function eg,Head@aa
$\endgroup$