擅长:python、mysql、java
<p>最终得到了预期的效果。感谢@mrzasa推荐finditer方法。谢谢@Arne,你的结果匹配大写。你知道吗</p>
<pre><code>pattern = r'(?i)^skills$'
regex = re.compile(pattern, re.IGNORECASE)
match_tup = [match.span() for match in re.finditer(r'(?i)^skills$',text,re.MULTILINE)]
print(match_tup)
</code></pre>