SynEdit has a special highlight mode for this:
CurEdit.SetHighlightSearch('TheWord', []);
2nd argument, is if you want to match full words only, or use regex
CurEdit.SetHighlightSearch('TheWord', [ssoWholeWord]);
see SynEdit.HighlightAllColor for setting the colors of the highlight
How do I use this? I tried
SynEdit1.CurEdit.SetHighlightSearch(Memo2.SelText, [ssoWholeWord]);
but got compiler errors: unit1.pas(44,14) Error: identifier idents no member "CurEdit"
and unit1.pas(44,69) Error: Identifier not found "ssoWholeWord"
Never mind. I used
SynEdit1.SetHighlightSearch(Memo2.SelText, []);
and everything worked as desired.