2015-09-04 293 views
1

我有一些問題用正則表達式過濾。正則表達式包含字符串,不包含另一個

我有多個條目像日誌:

2015-09-03 03:35:05,074 WARN [repo.sync.SyncTrackerComponent] missing event: CREATE 

2015-09-04 03:35:05,074 ERROR [repo.sync.SyncTrackerComponent] Unable to pull 2015-09-04 03:35:05,074 WARN [repo.sync.SyncTrackerComponent] missing event: CREATE

2015-09-04 11:21:58,638 ERROR [repo.jscript.ScriptLogger] Cost center review Id 473805 
2015-09-04 14:02:16,917 ERROR [repo.jscript.ScriptLogger] Tarea actual - GBS Review 

我使用正規表示法在記事本++由expeficic天來過濾誤差(即誤差今天)2015-09-04.*ERROR將輸出:

2015-09-04 03:35:05,074 ERROR [repo.sync.SyncTrackerComponent] Unable to pull 
2015-09-04 11:21:58,638 ERROR [repo.jscript.ScriptLogger] Cost center review Id 473805 
2015-09-04 14:02:16,917 ERROR [repo.jscript.ScriptLogger] Tarea actual - GBS Review 

我想過濾fo R實施例,這並不含有一定description.Im試圖用2015-09-04.*ERROR.*(?!.*Unable to pull)願意有這樣的輸出錯誤:

2015-09-04 11:21:58,638 ERROR [repo.jscript.ScriptLogger] Cost center review Id 473805 
2015-09-04 14:02:16,917 ERROR [repo.jscript.ScriptLogger] Tarea actual - GBS Review 

但它不work.What單曲錯誤的負查找?

任何幫助將不勝感激!

+1

嘗試'^(?!*無法拉)2015年9月4日,* ERROR。*'。 –

回答

0

問題(@stribizhev在評論中暗示)是在ERROR之後匹配.*,這意味着它在您的負面預測能夠(不)匹配任何內容之前匹配所有內容。

2015-09-04.*ERROR.*(?!.*Unable to pull) 
       /|\ 
       | 
       problem 

如果您將負向預測放在匹配的其餘部分之前,它應該可以工作。

2015-09-04.*ERROR(?!.*Unable to pull).* 

See Demo

+0

終於爲我工作的實際正則表達式是^(?!。*無法拉動*)2015-09-04。*錯誤。* 謝謝 –

相關問題