我想在 Python 3.x 中搜索一个位于另一个字符串开头的字符串
所以我有
for pattern, responses in substrings:
match = re.match(pattern, statement)
if match: # etc.
但是
如果其中一个子字符串是'no'
,则不仅第一个单词是“no”,而且例如是'noggin'
,也会找到该子字符串
如何仅在单词为 'no'
时搜索开头的 'no'
?
谢谢
最佳答案
关于python - 当匹配不起作用时如何在主字符串的开头查找子字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49391431/