Python Regex Negative Lookbehind
问题 The pattern (?<!(asp|php|jsp))\?.* works in PCRE, but it doesn't work in Python. So what can I do to get this regex working in Python? (Python 2.7) 回答1: It works perfectly fine for me. Are you maybe using it wrong? Make sure to use re.search instead of re.match : >>> import re >>> s = 'somestring.asp?1=123' >>> re.search(r"(?<!(asp|php|jsp))\?.*", s) >>> s = 'somestring.xml?1=123' >>> re.search(r"(?<!(asp|php|jsp))\?.*", s) <_sre.SRE_Match object at 0x0000000002DCB098> Which is exactly how