Problem with pattern matches for checked items in listview
Hi guys,
I need your help, I have a problem with the matches pattern for the checked items in the listview. I couldn't be able to find the solution by when I selected the checkboxes items in the listview and when I clicked on the button, the messagebox is suppose to be displaying but nothing have happens.
What I am trying to achieve is to find the matches in pattern that I have ticked the checkboxes items in the listview, then find the strings in my website that matched with the checked items in the listview and find the html tags id from the html source, e.g: www.mysite.com/images?user=tester&id=1. Then display the messagebox.
PHP:
PHP Code:
<p id="images"> <a href="images.php?id=?">Images</a></td>
The Code:
Code:
private: System::Void Button1_Click(System::Object^ sender, System::EventArgs^ e) {
for each (ListViewItem ^item in this->listView1->CheckedItems)
{
try
{
String ^URL1 = "http://www.mysite.com/link.php?user=tester";
HttpWebRequest ^request1 = safe_cast<HttpWebRequest^>(WebRequest::Create(URL1));
HttpWebResponse ^response1 = safe_cast<HttpWebResponse^>(request1->GetResponse());
StreamReader ^reader1 = gcnew StreamReader(response1->GetResponseStream());
String ^str1 = reader1->ReadToEnd();
String ^pattern1 = item->Text + "(<p id='images'>(.*?)</p>)";
MatchCollection ^matches1 = Regex::Matches(str1, pattern1);
Match ^m1 = Regex::Match(str1, pattern1);
for each (Match ^x1 in matches1)
{
array<String^> ^StrArr1 = x1->Value->ToString()->Split();
String ^test = (URL1 + x1->Value->ToString());
MessageBox::Show(test);
}
}
catch (Exception ^ex)
{
}
}
}
I am definately sure that the html tags has the correct tags name.
Any idea?