【发布时间】:2010-03-07 07:52:54
【问题描述】:
我正在研究响应过滤器。我试图用以下正则表达式捕获所有表达式:$sometext.sometext$:^\w+?.\w+?\$
在我的实现中它看起来像:
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 regex=@"^\\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$ 时,它不会被 write 方法中的正则表达式捕获。我错过了什么?
【问题讨论】:
-
你的替换方法不对。 Response.Filter 内容被分块。看west-wind.com/weblog/posts/2009/Nov/13/…