[英]Regular expression for “not in a list of values” without negative lookahead
I want to search for a string that doesn't exist in a list of strings by using regex. 我想使用正则表达式搜索字符串列表中不存在的字符串。 Is it possible to make a regex for that case without using negative lookahead ? 是否可以在不使用负前瞻的情况下针对这种情况制作正则表达式?
只需将正则表达式用于“在值列表中”,如果匹配则返回False
。
When you just search for a plain string in a list of strings you don't even need regex. 当您仅在字符串列表中搜索纯字符串时,您甚至不需要正则表达式。 you can just do string not in list_of_strings
你可以只string not in list_of_strings
做string not in list_of_strings
For example if you have 例如,如果您有
list_of_string = ['string1', 'string2', 'string3']
string = 'string4'
string not in list_of_strings
would result in True
string not in list_of_strings
将导致True
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.