擅长:python、mysql、java
<p>用另一种方法解决问题时,可以使用大写<code>Skill</code>:</p>
<pre><code>def get_match_index(keyword, text):
start_match = text.index(keyword)
end_match = start_match + len(text)
return start_match, end_match
</code></pre>
<p>,它将以这种形式返回与来自这个正则表达式的<code>span()</code>调用相同的结果:</p>
<pre><code>def get_match_index(keyword, text):
pattern = re.compile(f"(?<=\n){keyword}")
return pattern.search(text.lower()).span()
</code></pre>