Thread: How to split the returned strings?

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

    How to split the returned strings?

    Hi guys,

    I need your help, I am working on my program to compare the tags between mystrings1 and mystrings2. When the program have found the matches through on pattern1, it will extract the whole tags from the php source which I only want to extract the strings from mystrings1 tag while ignore the others.


    Code:
    System::Void Form1::timer1_Tick(System::Object^  sender, System::EventArgs^  e)
        timer1->Enabled = false;
        timer1::Stop();
    
        try
        {
            String ^URL1 = "http://www.mysite.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=\"mystrings2\">Enabled</td>)";
            MatchCollection ^matches1 = Regex::Matches(str1, pattern1);
    
            for each (Match ^x1 in matches1)
            {
                array<String^> ^StrArr1 = x1->Value->ToString()->Split();
                MessageBox::Show(x1->ToString());
            }
        }
        catch (Exception ^ex)
        {
        }
    }
    Do you know how i can extract the strings from mystrings1 while ignore the other tags when I get the returned strings?

    Any advice would be much appriecated.

    Thanks,
    Mark

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    This is not C++.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    It's either C# or M$'s munged up C++ for .net
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. split strings (and split thread)
    By mahi in forum C Programming
    Replies: 1
    Last Post: 10-31-2011, 06:56 AM
  2. Replies: 19
    Last Post: 12-14-2010, 07:57 PM
  3. Replies: 4
    Last Post: 07-24-2010, 07:24 AM
  4. split strings by 2 ASCII Character
    By haidan_dan in forum C Programming
    Replies: 1
    Last Post: 01-24-2010, 08:05 AM
  5. I've Returned
    By Krak in forum Game Programming
    Replies: 11
    Last Post: 05-06-2003, 11:53 AM