Парсинг регулярными выражениями - C#
Формулировка задачи:
Здравствуйте, не могу написать программу, у меня вот такая ошибка выходит:Форматы URI не поддерживаются.
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.Load("http://"+textBox1.Text);
string pattern = @"\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}";
RegexOptions option = RegexOptions.IgnoreCase;
Regex newReg = new Regex(pattern, option);
MatchCollection matches = newReg.Matches(doc.ToString());
foreach (Match mat in matches)
{
checkedListBox1.Items.Add(mat.ToString());
}Решение задачи: «Парсинг регулярными выражениями»
textual
Листинг программы
var myRequest = (HttpWebRequest)HttpWebRequest.Create("http://"+textBox1.Text);
var myResponse = (HttpWebResponse)myRequest.GetResponse();
var sr = new StreamReader(myResponse.GetResponseStream(),Encoding.GetEncoding(1251));
var html = sr.ReadToEnd();
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
string pattern = @"\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}";
RegexOptions option = RegexOptions.IgnoreCase;
Regex newReg = new Regex(pattern, option);
MatchCollection matches = newReg.Matches(doc.ToString());
foreach (Match mat in matches)
{
checkedListBox1.Items.Add(mat.ToString());
}