Split the returned strings

This is a discussion on Split the returned strings within the Windows Programming forums, part of the Platform Specific Boards category; Hi guys, Can you please help me with my code as I have a trouble with the returned strings that ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    40

    Split the returned strings

    Hi guys,

    Can you please help me with my code as I have a trouble with the returned strings that I have extracted from my php source to add the strings in my listview.

    I'm reading the tags of mystrings1 and mystrings2 for each paragraph from the php source. I got the returned strings which it looks like this:

    PHP Code:
    <p id='mystrings1'>my strings</p> | <a href="http://xfvasfasfasfasf">Link</a> </td> | <a href="delete.php?id=0">Delete</a> </td> | <span id="mystrings2">Enabled</td
    I want the returned strings to be like this when I reads the tags of mystrings1 and mystrings2 while ignore the other tags.

    PHP Code:
    <p id='mystrings1'>my strings</p> | <span id="mystrings2">Enabled</td

    Here's the code:

    Code:
    System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e)
    {
        timer1->Enabled = false;
        timer1::Stop();
    
        try
        {
            String ^URL1 = "http://programmingtsite.elementfx.com/myscript.php?user=test&pass=test";
            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 = "(<p id='mystrings1'>(.*?)</p>(.*?)<span id=\\"test / ">(.*?)</td>)";
            MatchCollection ^matches1 = Regex::Matches(str1, pattern1);
    
            for each (Match ^x1 in matches1)
            {
                array<String^> ^StrArr1 = x1->Value->ToString()->Split();
                MessageBox::Show(x1->ToString());
                ListViewItem ^item1 = gcnew ListViewItem("", 1);
      
             
     item1->SubItems->Add(x1->Value->ToString()->Replace("<p
     id='mystrings2'>", "")->Replace("</p>", ""));
                listView1::Items->AddRange(gcnew array<ListViewItem^> {item1});
                listView1->CheckBoxes = true;
    
                if (x1->Value->Contains("Enabled"))
                {
                    item1->Checked = true;
                }
            }
        }
        catch (Exception ^ex)
        {
        }
    }

    Do you know how I can ignore the other tags when I get the returned strings of mystrings1 and mystrings2??

    Any advice would be much appriecated.

    Thanks,
    Mark

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    Weird MS.Net C++ stuff moved to the windows board.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to split the returned strings?
    By mark103 in forum Windows Programming
    Replies: 2
    Last Post: 03-27-2012, 12:20 PM
  2. split strings (and split thread)
    By mahi in forum C Programming
    Replies: 1
    Last Post: 10-31-2011, 07:56 AM
  3. Replies: 19
    Last Post: 12-14-2010, 07:57 PM
  4. split strings by 2 ASCII Character
    By haidan_dan in forum C Programming
    Replies: 1
    Last Post: 01-24-2010, 08:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21