是否abcd efgh
存在abcd 123456 efgh
?
我希望返回值为true。
发布于 2018-09-05 10:43:24
'abcd 123456 efgh'中没有字符串'abcd efgh'。但是,如果您希望匹配,则可以使用以下正则表达式:^abcd.*efgh$
这将查找严格以“abcd”开头并以“efgh”结尾的字符串,而不关注这两者之间的内容。
你可以在python中找到有关正则表达式运算符的更多信息:https://docs.python.org/3/library/re.html
发布于 2018-09-05 12:06:54
可能是更好的方法,但你可以使用for循环:
string = 'abcd efgh 1234556'
newstring = ''
for x in string:
newstring = newstring + x
if newstring == 'abcd efgh':
print(True)
https://stackoverflow.com/questions/-100002564
复制相似问题