Click here to Skip to main content
15,887,436 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have auto generated HTML source text file look like this:

JavaScript
<!--
//--></SCRIPT>
<script language=JavaScript>
var staMgrParaInf = new Array(1,0,0,0,10,48,2,1,0,0,0 );
</script><script language=JavaScript>var staEntryInf = new Array("192.168.1.56",0,87357,111282,10432836,103871290,1,1,41,52,"192.168.1.21",0,394,42991358,55037052,5,7,260,10360);</script>
</HEAD>
<SCRIPT language="javascript">
    var pageRefreshTime = 10;


i want to extract only this text

VB
"192.168.1.56",0,87357,111282,10432836,103871290,1,1,41,52,
"192.168.1.21",0,39439,42063,2991358,55037052,5,7,260,10360


Please help me

i try this code

C#
private void button1_Click(object sender, EventArgs e)
{
    String line;
    String filetext = null;
    int count = 0;
    using (System.IO.StreamReader reader = new System.IO.StreamReader("C:\\viewsource.txt"))
    {
        while ((line = reader.ReadLine()) != null)
        {
            if (count == 0)
            {

                if (line.StartsWith("<"))
                {

                }
                else
                {
                    filetext = filetext + line;
                }
            }
            else
            {
                if (line.StartsWith("<"))
                {

                }
                else
                {
                    filetext = filetext + "\n" + line;
                }
            }
            count++;
        }
        Trace.WriteLine(filetext);

        int start = filetext.IndexOf("(") + 1;
        int end = filetext.IndexOf(")", start);
        string result = filetext.Substring(start, end - start);
        textBox1.Text = result;
        reader.Close();
    }
}


My result only this

VB
1,0,0,0,10,48,2,1,0,0,0


i want to extract only this text

VB
"192.168.1.56",0,87357,111282,10432836,103871290,1,1,41,52,
"192.168.1.21",0,39439,42063,2991358,55037052,5,7,260,10360
Posted
Updated 11-Aug-15 21:41pm
v3
Comments
What have you tried?
isuru chanaka 12-Aug-15 3:36am    
i try this code

private void button1_Click(object sender, EventArgs e)
{
String line;
String filetext = null;
int count = 0;
using (System.IO.StreamReader reader = new System.IO.StreamReader("C:\\viewsource.txt"))
{
while ((line = reader.ReadLine()) != null)
{
if (count == 0)
{

if (line.StartsWith("<"))
{

}
else
{
filetext = filetext + line;
}
}
else
{
if (line.StartsWith("<"))
{

}
else
{
filetext = filetext + "\n" + line;
}
}
count++;
}
Trace.WriteLine(filetext);

int start = filetext.IndexOf("(") + 1;
int end = filetext.IndexOf(")", start);
string result = filetext.Substring(start, end - start);
textBox1.Text = result;
reader.Close();
}
}

Try:
(?<=Array\()".+(?=\))
 
Share this answer
 
Try this regex pattern: \W((?:\d{1,3}\.){3}\d{1,3}..(?:\d{1,9},){8}\d{1,9})\W
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900