所以我想要一个像这样工作的正则表达式:
获取[a-z0-9.-]但不是'example','example1','example3','user','home','h3llo'
编辑
我需要.htaccess中的这个正则表达式
例子可以是我想要的东西.
您可能需要提供更多您想要匹配的示例,但这是一个开始: ^(?!example[13]?)[a-z0-9.-]+$
>>> 'Match' if re.match('(?!example[13]?)[a-z0-9.-]', 'example') else 'No match'
'No match'
>>> 'Match' if re.match('(?!example[13]?)[a-z0-9.-]', 'example1') else 'No match'
'No match'
>>> 'Match' if re.match('(?!example[13]?)[a-z0-9.-]', 'example3') else 'No match'
'No match'
>>> 'Match' if re.match('(?!example[13]?)[a-z0-9.-]', 'dsfhdsagfir') else 'No match'
'Match'
Run Code Online (Sandbox Code Playgroud)
它使用负向前瞻来对您不想匹配的字符串进行失败.