Searching Text

The search operation scans the text widget for a string that matches a pattern. The index of the text that matches the pattern is returned. The search starts at an index and covers all the text widget unless a stop index is supplied. You can use end as the stop index to prevent the search from wrapping back to the beginning of the document. The general form of the search operation is this:

$t search ?options? pattern index ?stopIndex?

Table 33-4 summarizes the options to the search operation:

Table 33-4. Options to the search operation.
-forwardSearches forward from index. This is the default.
-backwardSearches backward from index.
-exactMatches pattern exactly. This is the default.
-regexpUses regular expression pattern matching. ...

Get Practical Programming in Tcl & Tk, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.