Problem with pattern matches for checked items in listview

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi guys,<br/>
<br/>
I need your help, I have a problem with the matches pattern for the checked items in the listview. I couldnt 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. <br/>
<br/>
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.<br/>
<br/>
PHP:<br/>
PHP:
<p id="images   images.php?id=? Images </td>
<br/>
<br/>
The Code:<br/>
Code:
<br/>
private: System::Void Button1_Click(System::Object^  sender, System::EventArgs^  e) {<br/>
<br/>
<br/>
             for each (ListViewItem ^item in this->listView1->CheckedItems)<br/>
             {<br/>
                 try<br/>
                 {<br/>
                     String ^URL1 = "http://www.mysite.com/link.php?user=tester";<br/>
                      HttpWebRequest ^request1 = safe_cast<HttpWebRequest^>(WebRequest::Create(URL1));<br/>
                      HttpWebResponse ^response1 = safe_cast<HttpWebResponse^>(request1->GetResponse());<br/>
                      StreamReader ^reader1 = gcnew StreamReader(response1->GetResponseStream());<br/>
                      String ^str1 = reader1->ReadToEnd();<br/>
                      String ^pattern1 = listView1->SelectedItems[0]->SubItems[1]->Text + "(<p id=images>(.*?) )";<br/>
                      MatchCollection ^matches1 = Regex::Matches(str1, pattern1);<br/>
                      Match ^m1 = Regex::Match(str1, pattern1);<br/>
<br/>
<br/>
                     for each (Match ^x1 in matches1)<br/>
                     {<br/>
                         array<String^> ^StrArr1 = x1->Value->ToString()->Split();<br/>
                         String ^test = (URL1 + x1->Value->ToString());<br/>
                         MessageBox::Show(test);<br/>
                     }<br/>
                 }<br/>
                 catch (Exception ^ex)<br/>
                 {<br/>
<br/>
                 }<br/>
             }<br/>
<br/>
         }<br/>
<br/>
<br/>
I am definately sure that the html tags has the correct tags name as well the regex.<br/>
<br/>
Do you have any idea why the messagebox will not display the ids from the html tags?

View the full article
 
Back
Top