开发者

Search that returns array of founds in wxPython?

开发者 https://www.devze.com 2023-02-06 06:22 出处:网络
in wxPython Styled text, There is a FindText that finds first occurrence of text searched. Is there a wa开发者_运维问答y to find all occurrences and put them into list or dict in one go?If there\'s no

in wxPython Styled text, There is a FindText that finds first occurrence of text searched. Is there a wa开发者_运维问答y to find all occurrences and put them into list or dict in one go?


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)]
0

精彩评论

暂无评论...
验证码 换一张
取 消