Notepad ++正则表达式查找包含str1而不包含str2

iht*_*tus 1 regex notepad++

1. The CAT goes up and down the ROAD.
2. The CAT goes up and down the CITY.
3. The ROAD goes up and down the CAT.
Run Code Online (Sandbox Code Playgroud)

正则表达式:(CAT)(.*?)(ROAD)将找到包含CAT和ROAD的行

现在我需要找到包含CAT而不包含ROAD的行.

试过(CAT)(.*?)(?!ROAD)但似乎不正确.

Yos*_*ssi 6

您可以一起使用消极和积极的前瞻.检测具有CAT的行是否为正,否定否定ROAD.

^(?=.*CAT)(?!.*ROAD)(.*)
Run Code Online (Sandbox Code Playgroud)

我还在最后添加.*了选择这些行.