0
我收到Web響應並嘗試在其中查找ID。 我寫道:RegEx返回空字符串
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
出了什麼問題?
如果您向我們提供了'readStream.ToString()'的內容,它可能會有所幫助,這可能不是您認爲的內容。 – Rawling
'readStream.ToString()'將返回'System.IO.StreamReader' - 不是流的內容。嘗試使用'readStream.ReadToEnd()'代替。 – samjudson