Split the strings

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi guys,<br/>
<br/>
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.<br/>
<br/>
Im reading the tags of mystrings1 and mystrings2 for each paragraph from the php source. I got the returned strings which it looks like this:
<div style="margin:20px
<div style="margin-bottom:2px PHP Code:
<div dir="ltr" style="margin:0px; padding:3px; border:1px inset; width:900px; height:34px; text-align:left
<code style="white-space:nowrap
Code:
<span style="color:#000000 <span style="color:#007700 <<span style="color:#0000BB p id<span style="color:#007700 =<span style="color:#DD0000 mystrings1<span style="color:#007700 ><span style="color:#0000BB my
 strings<span style="color:#007700 </<span style="color:#0000BB p<span style="color:#007700 > | <<span style="color:#0000BB a href<span style="color:#007700 =<span style="color:#DD0000 "http://xfvasfasfasfasf"<span style="color:#007700 ><span style="color:#0000BB Link<span style="color:#007700 </<span style="color:#0000BB a<span style="color:#007700 >
 </<span style="color:#0000BB td<span style="color:#007700 > | <<span style="color:#0000BB a href<span style="color:#007700 =<span style="color:#DD0000 "delete.php?id=0"<span style="color:#007700 ><span style="color:#0000BB Delete<span style="color:#007700 </<span style="color:#0000BB a<span style="color:#007700 >
 </<span style="color:#0000BB td<span style="color:#007700 > | <<span style="color:#0000BB span id<span style="color:#007700 =<span style="color:#DD0000 "mystrings2"<span style="color:#007700 ><span style="color:#0000BB Enabled<span style="color:#007700 </<span style="color:#0000BB td<span style="color:#007700 >
<br/>
[/code]

I want the returned strings to be like this when I reads the tags of mystrings1 and mystrings2 while ignore the other tags.
<div style="margin:20px
<div style="margin-bottom:2px PHP Code:
<div dir="ltr" style="margin:0px; padding:3px; border:1px inset; width:900px; height:34px; text-align:left
<code style="white-space:nowrap
Code:
<span style="color:#000000 <span style="color:#007700 <<span style="color:#0000BB p id<span style="color:#007700 =<span style="color:#DD0000 mystrings1<span style="color:#007700 ><span style="color:#0000BB my
 strings<span style="color:#007700 </<span style="color:#0000BB p<span style="color:#007700 > | <<span style="color:#0000BB span id<span style="color:#007700 =<span style="color:#DD0000 "mystrings2"<span style="color:#007700 ><span style="color:#0000BB Enabled<span style="color:#007700 </<span style="color:#0000BB td<span style="color:#007700 >
<br/>
[/code]

<br/>
Heres the code:
<div style="margin:20px
<div style="margin-bottom:2px Code:
<pre class="x_alt2" dir="ltr" style="margin:0px; padding:3px; border:1px inset; width:900px; height:498px; text-align:left 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>(.*?) (.*?)<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(" ", ""));
listView1::Items->AddRange(gcnew array<ListViewItem^> {item1});
listView1->CheckBoxes = true;

if (x1->Value->Contains("Enabled"))
{
item1->Checked = true;
}
}
}
catch (Exception ^ex)
{
}
}[/code]

<br/>
Do you know how I can ignore the other tags when I get the returned strings of mystrings1 and mystrings2??<br/>
<br/>
Any advice would be much appriecated.<br/>
<br/>
Thanks,<br/>
Mark

View the full article
 

Similar threads

Back
Top