在python中搜索精确单词
找到了hugh bothwell的答案 非常有用,但现在我想这样做在python中搜索精确单词,python,regex,string,Python,Regex,String,找到了hugh bothwell的答案 非常有用,但现在我想这样做 findWholeWord('object')('object test') # -> <match object> findWholeWord('object')('object-group') # -> None findWholeWord('object')('objecttest')#-> FindHoleword('object')('objec
findWholeWord('object')('object test') # -> <match object>
findWholeWord('object')('object-group') # -> None
findWholeWord('object')('objecttest')#->
FindHoleword('object')('object-group')#->None
有人吗?使用正则表达式:
'object(?=[\W\D\S\s]*?)'
这应该行得通
(?:^|(?<=\s))object(?=\s|$)
if re.findall(r"(?:^|(?<=\s))object(?=\s|$)",test_str):
print "yes present"