RegEx返回空字符串

时间:2013-12-10 12:44:38

标签: c# regex httpresponse

我正在收到网络回复并尝试在其中找到ID。 我写道:

HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
var regex = new Regex(@"([0-9]+)(?=\) title=)");
return regex.Match(readStream.ToString()).ToString(); //suppose there is a problem

有什么问题?

1 个答案:

答案 0 :(得分:3)

readStream.ToString应该返回类似System.Object.StreamReader的内容,因为它是此方法的默认实现。

尝试改为使用readStream.ReadToEnd()