Regular expression syntax for “match nothing”?

前端 未结 6 915
清酒与你
清酒与你 2021-01-31 00:58

I have a python template engine that heavily uses regexp. It uses concatenation like:

re.compile( regexp1 + \"|\" + regexp2 + \"*|\" + regexp3 + \"+\" )
<         


        
6条回答
  •  南笙
    南笙 (楼主)
    2021-01-31 01:33

    (?!) should always fail to match. It is the zero-width negative look-ahead. If what is in the parentheses matches then the whole match fails. Given that it has nothing in it, it will fail the match for anything (including nothing).

提交回复
热议问题