Kevin Altis:
> I will add a Replace dialog once we are using wxPython 2.3.2. I also
> need to work out how I'm going to do whole word matches in the
> text. I don't think there is an option just using a plain Python string
> operation, so I probably have to resort to using a regular expression.
> Perhaps some text wizard like Neil will enlighten me. :)
Regular expressions can be used but I find them confusing. If you want to
combine a user entered string with a regular expression search then you need
to check the user string for regular expression metacharacters and quote
them.
A wizard's hat is reasonably similar to a dunce's cap so I chose the
essentially dumb approach of looping, searching for the string and if found
checking if the match is a word. If it is then report success, else try
again. You can define a word in many ways, often as starting and ending with
a character from the set of word characters (often A-Za-z0-9) and with the
characters before and after the match not being from this set.
Scintilla's concept of a word is a little more complex than that but that
is because it wants to do a good job on programming text where sequences of
punctuation such as "->" or identifiers next to punctuation such as ".text"
make good "word" searches.
Neil
|