[QScintilla] Search Whole Word matches Only on regular expression symbol

Baz Walter bazwal at ftml.net
Thu Oct 10 18:06:31 BST 2013


On 10/10/13 01:29, Han Lun Tan wrote:
> Hi,
>
> I using FindFirst to do search, turn on wo = true to search for whole word matches only.
> However, I found some bug as below text
>
> Known that I have turned on ONLY wo = true for whole word matches.
> Given I have text as below, I search for "$test" It returns nothing.
> ($test)
> ($test)
> ($test)
>
> If I change my search text to "test", I can find all the 3 lines results.
>
> Is this a bug ? Any workaround?

It's not a bug: by default, "$" won't be counted as a word character. 
However, it is possible to change the set of characters that Scintilla 
treats as word-characters (and also what is treated as whitespace and 
punctuation).

At the moment, I don't think QScintilla provides a way to do this 
through the high-level api. (It is possible to re-implement the 
QSciLexer wordCharacters function, but I think this will only directly 
affect auto-completion). Instead, you could try setting the 
word-characters through the low-level api, i.e.:

     SendScintilla(SCI_SETWORDCHARS, characters)

Note that setting the word-characters in this way will change the 
behaviour of Scintilla in several ways, not just finding text. For 
instance, double-clicking a word to select it will include any new 
characters you have added.

For more info, see the Scintilla docs:

     http://www.scintilla.org/ScintillaDoc.html#SCI_SETWORDCHARS

And also the QsciScintillaBase docs:

 
http://pyqt.sourceforge.net/Docs/QScintilla2/classQsciScintillaBase.html#pub-methods

-- 
Regards
Baz Walter


More information about the QScintilla mailing list