在Python中匹配字符串序列中的2个单词
我在Python中有一大组字符串 例如: 我需要选择那些包含在Python中匹配字符串序列中的2个单词,python,regex,Python,Regex,我在Python中有一大组字符串 例如: 我需要选择那些包含https://github.com/和/commit/ 我的代码: 此代码匹配上面示例中的所有4种情况。我需要它只匹配第二个url 我该怎么做 您不能使用和那样的,您需要单独声明: if "https://github.com/" in url and "/commit/" in url: print("OK") else: print("not okay") (x和y)在z中到x在z中,y在z中。您能提供更多详细信
https://github.com/
和/commit/
我的代码:
此代码匹配上面示例中的所有4种情况。我需要它只匹配第二个url
我该怎么做 您不能使用
和那样的,您需要单独声明:
if "https://github.com/" in url and "/commit/" in url:
print("OK")
else:
print("not okay")
(x和y)在z中
到x在z中,y在z中
。您能提供更多详细信息吗
if ("https://github.com/" and "/commit/") in url:
print("OK")
else:
print("not okay")
if "https://github.com/" in url and "/commit/" in url:
print("OK")
else:
print("not okay")