我正在试着得到第二个匹配单词技能的索引。我想匹配的关键字,是目前单独而不是在一个句子。你知道吗
keyword = "skills"
def get_match_index(keyword, text):
for sentence in text.split('\n'):
if keyword == sentence.lower().strip():
print(re.search(keyword,text))
这将返回第一次搜索的索引。 这是课文。你知道吗
Assessed and changed skills required to take company to next level in the IT, HR, Accounting.
-
College Station
Skills
我想在这里匹配关键字的第二个实例-“技巧”,一个标题,而不是一个句子。你知道吗
用另一种方法解决问题时,可以使用大写
Skill
:,它将以这种形式返回与来自这个正则表达式的
span()
调用相同的结果:可以使用^{} 而不是
search
医生说:
以及
最终得到了预期的效果。感谢@mrzasa推荐finditer方法。谢谢@Arne,你的结果匹配大写。你知道吗
相关问题 更多 >
编程相关推荐