Search tkinter text widget contents using regular expression Search tkinter text widget contents using regular expression tkinter tkinter

Search tkinter text widget contents using regular expression


The regular expression specified is interpreted by tcl, not by python.

Tcl use different syntax for word boundary: \y instead of \b. (See Word boundaries, especially Tcl Word Boundaries part.)

The line should be replaced with:

index = self.text.search(r'\y%s\y' % myWord, INSERT, backwards=True, regexp=True)