Regex: what does (?! …) mean?

前端 未结 6 1567
既然无缘
既然无缘 2021-02-12 21:46

The following regex finds text between substrings FTW and ODP.

/FTW(((?!FTW|ODP).)+)ODP+/

What does the (?!...) do?

6条回答
  •  清酒与你
    2021-02-12 22:36

    It means "not followed by...". Technically this is what's called a negative lookahead in that you can peek at what's ahead in the string without capturing it. It is a class of zero-width assertion, meaning that such expressions don't capture any part of the expression.

提交回复
热议问题