2013-04-23 83 views
0

如何獲得沒有單引號或雙引號的前導和後綴字符的目標單詞?目前下面的表達式匹配全部。我嘗試插入[^'],但沒有奏效。如何從正則表達式中排除前導單引號或雙引號

[\b(?i)Test\b] 

test - match 
Test - match 
TEST - match 
'test' - I do not want this to match 
"test" - I do not want this to match 
+0

嗎? – Izzy 2013-04-23 16:27:41

+0

我想匹配測試而不是'測試'的段落,並忽略套管。 – TroyS 2013-04-23 16:33:04

回答

0

您可以使用此正則表達式要匹配``從「test'` test`

(^|[^'"])test([^'"]|$) 
+0

我嘗試過,但它不工作加上我需要保持邊界\ b – TroyS 2013-04-23 15:59:38

+0

@ tszoro刪除'(?i)'..爲我工作 – Anirudha 2013-04-23 16:38:50

+0

這隻匹配'test'而不是'TEST'或'Test' ... – Izzy 2013-04-23 16:49:54

相關問題