搜索返回wxPython中的founds数组?

时间:2011-01-20 13:44:48

标签: wxpython

在wxPython样式文本中,有一个FindText可以找到第一次出现的文本。 有没有办法找到所有事件并将它们一次性放入列表或字典?

1 个答案:

答案 0 :(得分:1)

如果没有内置函数,你可以在StyledTextCtrl的内容上使用re.finditer:

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