So let’s summarize.
The script worked before but not as expected
because the original version matched only whole words
and not if the searched word is part of another word.
To change this I changed
editor.research('\\b{0}\\b'.format(selected_text), lambda m: matches.append(m.span(0)))
to
editor.research('{0}'.format(selected_text), lambda m: matches.append(m.span(0)))
then I thought maybe there can be also a difference in notation
therefore I included regex module
import re
and added the ignorecase flag to the research function.
editor.research('{0}'.format(selected_text), lambda m: matches.append(m.span(0)),re.IGNORECASE)
Which broke not only your uploaded code, which by the way is working for me,
but also the python script plugin??
This is weird. There is nothing fancy here. re module is part of the standard python lib.
OK, please comment the import re line
# import re
and change the editor.research … to
editor.research('{0}'.format(selected_text), lambda m: matches.append(m.span(0)))
and do another test.
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.
Traceback (most recent call last):
File "...\Notepad++\plugins\Config\PythonScript\scripts\Highlight.py", line 42, in sci_callback_DOUBLECLICK
colorize()
File "...\Notepad++\plugins\Config\PythonScript\scripts\Highlight.py", line 29, in colorize
editor.research('{0}'.format(selected_text), lambda m: matches.append(m.span(0)),re.IGNORECASE)
NameError: global name 're' is not defined
May I ask you which OS, npp and python script plugin version you use?
Cheers
Claudia