擅长:python、mysql、java
<p>由于您的需求不明确,这可能无法解决您的确切问题,但它应该给您一个开始。这将返回匹配<code>h+o+u+s+e</code>正则表达式的字符串的第一个和第二个实例之间的字母数。你知道吗</p>
<pre><code>import re
s = 'hoouseeqwehouusseee'
def length_of_first_gap(test_string, word):
pattern = '+'.join(list(word))
return len(re.split(pattern, test_string)[1])
>>> length_of_first_gap(s, 'house')
>>> 4
</code></pre>