python多正则表达式

2024-10-04 01:29:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要对一个字符串应用多个正则表达式,如下所示:

regex = re.compile("...")
regex2 = re.compile("...")
regex3 = re.compile("...")
regex4 = re.compile("...")
if regex.match(string) == None and regex2.match(string) == None and regex3.match(string) == None and regex4.match(string) == None:

我想知道是否有另一种方法可以合并或组合单个正则表达式,或者我是否已经在用“正确的方法”进行合并?在


Tags: and方法字符串renonestringifmatch