Skip to main content
added 90 characters in body
Source Link
David G. Stork
  • 42.3k
  • 3
  • 37
  • 106
highlight[mystring_String, where_List] :=
 
 Row@{StringTake[mystring, {1, where[[1]] - 1}], 
      Style[StringTake[mystring, where], Red], 
      StringTake[mystring, {where[[2]] + 1, StringLength[mystring]}]}

highlight["abcdefghijkl", {3, 5}]

If you want to highlight a single character,

highlight["abcdefghijkl", {3, 3}]
highlight[mystring_String, where_List] :=
 
 Row@{StringTake[mystring, {1, where[[1]] - 1}], 
   Style[StringTake[mystring, where], Red], 
   StringTake[mystring, {where[[2]] + 1, StringLength[mystring]}]}

highlight["abcdefghijkl", {3, 5}]
highlight[mystring_String, where_List] :=
 
 Row@{StringTake[mystring, {1, where[[1]] - 1}], 
      Style[StringTake[mystring, where], Red], 
      StringTake[mystring, {where[[2]] + 1, StringLength[mystring]}]}

highlight["abcdefghijkl", {3, 5}]

If you want to highlight a single character,

highlight["abcdefghijkl", {3, 3}]
Source Link
David G. Stork
  • 42.3k
  • 3
  • 37
  • 106

highlight[mystring_String, where_List] :=
 
 Row@{StringTake[mystring, {1, where[[1]] - 1}], 
   Style[StringTake[mystring, where], Red], 
   StringTake[mystring, {where[[2]] + 1, StringLength[mystring]}]}

highlight["abcdefghijkl", {3, 5}]