I hope that code itself is self-explaining mostly therefore I only describe
the critical parts and how it should be used.

The script itself registers two callback functions,
sci_callback_DOUBLECLICK and sci_callback_INDICATORCLICK.

When you doubleclick on a text the function gets called
and tries to find the selected word in the 2nd view. If it
can be found it marks it. If you click (only one mouse click)
on the marked text, highlighting disappears.
If you click anywhere else only the highlighted text in this view
loses its markings. If you close the second view and double click
on a text then all callbacks will be cleared.

So, after you created the script
run it
open both views and
play with it by double clicking words.

As already described, 2nd view needs to be active before
you double click words or callbacks get cleared and you
need to run the script again.

One minor issue I discovered while testing.
It happened to me that words which were already
highlighted got cleaned again. Not sure why?
But it looks like this only happens if you
often double click in short time.

You do not need to do anything in the python script console, just open it, it serves as an
error output window if something within the python code is wrong.
For example if you add the re.IGNORECASE flag but you do not import re module first
the error would be shown in the console window as soon as you double click on a word.