When we need to find a specific piece of text within a Text widget, there is a method called search which will allow us to do this easily.
The search method can take quite a lot of arguments:
- pattern: The pattern to match. This can be either an exact match or a regular expression.
- index: Where to begin the search from.
- stopindex: Where to stop ending a search. If this is not specified, the search will loop.
- forwards: Whether to search from the top to the bottom (this is the default).
- backwards: Whether to search from bottom to top.
- exact: Exact match instead of a regular expression (this is the default).
- regexp: Indicates that the pattern supplied is a regular expression.
- nocase: Whether to ignore case.
- count: A variable which will be updated with the length of the match.
The only mandatory arguments are the search pattern and the starting index.
The Search method...