使用python list 查找所有匹配元素的位置实例
如下所示:
import re word = "test" s = "test abcdas test 1234 testcase testsuite" w = [m.start() for m in re.finditer(word, s)] print(w)
如下所示:
import re word = "test" s = "test abcdas test 1234 testcase testsuite" w = [m.start() for m in re.finditer(word, s)] print(w)