我在響應過濾器上工作。我試着去捕捉所有expresion:$ sometext.sometext $有以下正則表達式:^ \ w + \ w + \ $響應過濾器asp.net
我在執行它看起來像:
public override void Write(byte[] buffer, int offset, int count)
{
// Convert the content in buffer to a string
string contentInBuffer = UTF8Encoding.UTF8.GetString(buffer);
string [email protected]"^\\w+?\.\w+?\$";
RegexOptions options = RegexOptions.Multiline;
MatchCollection matches = Regex.Matches(contentInBuffer , regex, options);
foreach (Match match in matches)
{
string value = match.Value;
}
outputStream.Write(UTF8Encoding.UTF8.GetBytes(contentInBuffer), offset, UTF8Encoding.UTF8.GetByteCount(contentInBuffer));
}
問題是當我在$ aspx頁面上寫$ Catch.Me $它不會被寫入方法中的正則表達式所捕獲。我在想什麼?
您的替換方法是錯誤的。 Response.Filter內容被分塊。看看http://www.west-wind.com/weblog/posts/2009/Nov/13/Capturing-and-Transforming-ASPNET-Output-with-ResponseFilter – 2013-04-19 16:15:06