EditorWindow : Change the color of words in a Label String

Hello everyone :slight_smile:

Here is what I developped to find words in Texts or TextsMeshPro from the scene.
But I would like to change the color of words found, like in the second image.

alt text

What I’d like to have :
alt text

How could I change the color of words in a string ?
What I have right now is a label like that :

var areaStyle = new GUIStyle(GUI.skin.label);
areaStyle.wordWrap = true;
areaStyle.fontSize = 14;
areaStyle.margin = new RectOffset(2, 0, 10, 10);
areaStyle.CalcSize(new GUIContent(_textsWithWord*.text));*

EditorGUILayout.LabelField(_textsWithWord*.text, areaStyle);*
Thanks for your help in advance !

How about using rich text tags? Just wrap the word in a color tag

"Some text before <color=yellow>borderline</color> and some text after"

If you want to do a search and highlight all the words you can simply use

highlightedText = originalText.Replace(searchWord, "<color=yellow>"+searchWord+"</color>");