2012-04-19 44 views

回答

1

我認爲這應該工作:

Response\.Redirect\s*\(.*?(?<!true\s*\,\s*true\s*)\); 

搜索「的Response.Redirect」, - 後跟0或多個空格 - 然後是( - 後跟任意字符的序列最短 - 不會以true,true結束);

+0

我不認爲VS搜索支持lookarounds。 (但它應該...) – stema 2012-04-19 09:01:34

+0

感謝您的努力,但是當我使用它時,它找不到任何結果。 (即使有) – Stefanvds 2012-04-19 09:08:09

+0

PS:你不必介意空間。它總是格式化的,所以它是真實的,真實的);你(沒有)尋找:) – Stefanvds 2012-04-19 09:13:50

0

試試這個:

true, true\);$ 

解釋:

  • )是特殊字符,所以你需要逃避它。
  • $最後會以正則表達式匹配字符串結尾。

要匹配X和無法比擬的Y,然後嘗試:

$regex1 = '/^Response\.Redirect\(/'; 
$regex2 = '/true, true\);$/'; 

然後:

if (preg_match($regex1, $s) && !preg_match($regex2, $s)) { // match } else { // not match } 

例子:

$s = 'Response.Redirect("something", true, true);'; // false 
$s = 'Response.Redirect("something");'; // true 
$s = '("something", true, true);'; // false 

對不起PHP中的樣本。但是你可以修改邏輯的正則表達式&。

+0

它必須以Response.Redirect – Stefanvds 2012-04-19 08:06:57

+0

開頭這將找到OP不想找到的那些! – stema 2012-04-19 08:08:12

+0

@stema對不起,我看錯了這個問題。我編輯了答案。希望它有幫助:-) – 2012-04-19 08:26:18