using System;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
namespace Working
{
class Program4
{
static string errorurl =
"http://www.realtor.ca/propertyDetails.aspx?propertyId=8692663";
static void Main(string[] args)
{
string s;
s = getWebpageContent(errorurl);
s = removeNewLineCharacters(s);
getFields(s);
Console.WriteLine("End");
}
public static void getFields(string html)
{
Match m;
string fsRE = @"ismeasurement.*?>.*?(\d+).*?sqft";
m = Regex.Match(html, fsRE, RegexOptions.IgnoreCase);
}
private static string removeNewLineCharacters(string str)
{
string[] charsToRemove = new string[] { "\n", "\r" };
foreach (string c in charsToRemove)
{
str = str.Replace(c, "");
}
return str;
}
static string getWebpageContent(string url)
{
WebClient client = new WebClient();
client.Headers.Add("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2;
.NET CLR 1.0.3705;)");
Stream data = client.OpenRead(url);
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
data.Close();
reader.Close();
return s;
}
}
}
이 프로그램이 중단됩니다. 내가 removeNewLineCharacters에() 함수를 호출을 제거 RegexOptions.IgnoreCase 옵션 또는 을 제거 할 때 제대로 실행됩니다.
사람은, 제발 무슨 일이 일어나고 있는지 말해 줄 수 있을까요? 많은 게으른 일치를보고왜이 C# 정규식이 내 프로그램을 중단 시키나요?
하면 프로그램이 충돌하지 않습니다. 멈췄다. – Foole