Reputation: 3445
in wxPython Styled text, There is a FindText that finds first occurrence of text searched. Is there a way to find all occurrences and put them into list or dict in one go?
Upvotes: 2
Views: 70
Reputation: 5161
If there's no built-in function, you can just use re.finditer on the contents of the StyledTextCtrl:
import re
full_text = my_stc.GetText()
search_string = 'a string to find'
matches = [i.start() for i in re.finditer(search_string, full_text)]
Upvotes: 1