2024-09-28 20:51:13 发布
网友
找到了休博思韦尔的答案
Python - Check If Word Is In A String
很有用,但现在我想让它发生
findWholeWord('object')('object test') # -> <match object> findWholeWord('object')('object-group') # -> None
有人吗?你知道吗
(?:^|(?<=\s))object(?=\s|$)
您可以将这个正则表达式与re.findall一起使用来检查它是否存在。你知道吗
re.findall
像这样的
if re.findall(r"(?:^|(?<=\s))object(?=\s|$)",test_str): print "yes present"
使用正则表达式:
'object(?=[\W\D\S\s]*?)'
这应该管用。你知道吗
您可以将这个正则表达式与
re.findall
一起使用来检查它是否存在。你知道吗像这样的
使用正则表达式:
这应该管用。你知道吗
相关问题 更多 >
编程相关推荐