2016-11-22 119 views
1

在Dreamweaver中,我試圖找到 「無」 字沒有這些表情: display:nonedisplay = "none"找到與正則表達式排除

我的最後一次嘗試是:

([\w ]*)(?!display:|display = ")none([\w ]*) but it found all words "none" 
+0

你能解釋一下你在做什麼?用別的東西代替東西?另外,請嘗試'\ b(?<!display:| display =「)none \ b(?!」)''。或者['\ b(?<!display:| display =「(?= none」))none \ b'](https://regex101.com/r/CGPTZZ/2)。 –

+0

只需在我的代碼中搜索,而不是替換。你的解決方案工作得更好,但仍然顯示:無 – usualuser

+0

然後,我認爲上面的第二個正則表達式應該工作,請檢查。 [它不匹配'display:none'](https://regex101.com/r/CGPTZZ/3)。 –

回答

0

在記事本++ 7.2.1 ,你可以使用負lookbehinds:

\b(?<!\bdisplay:)(?<!\bdisplay = ")none\b 

馬克功能使用它標記您需要查找和檢查的所有事件。

詳細

  • \b - 領先字邊界
  • (?<!\bdisplay:) - 必須不存在display:整個單詞的當前位置之前
  • (?<!\bdisplay = ") - 必須沒有前是display = "整個單詞當前位置
  • none\b - 整個單詞nonenone隨後用\b尾字邊界)

見下圖:

enter image description here

+0

對不起,我正在做一些測試,你的第二個解決方案實際上不工作(根本沒有任何回報)。但你的第三個解決方案完美地工作,非常感謝!確定在記事本++ 7.1也。 – usualuser

+0

您知道,NPP正在使用Boost正則表達式庫,在線PCRE正則表達式測試和Notepad ++中實際可用的測試之間可能存在差異。 –

+0

很高興爲你效勞。請考慮通過點擊左側的✓接受答案(請參閱[如何接受SO答案](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)) 。 –