<input type="radio" name="selection" onClick="selectData 'S200507000009A','','A','110201','Pre-test','WR','');" onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData('S200507000009A','','A','110202','Basic Function test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
这是第一种,需要提取的是onClick="selectData 'S200507000009A','','A','110201','Pre-test','WR','');"和onClick="selectData('S200507000009A','','A','110202','Basic Function test','WR','');" ----也就是从onClick=到分号.
第二种情况:
<a onClick="displayContent('/DMS','S200507000009A','110201','A','F2109963');" onMouseOver="this.style.cursor='hand';">
<a onClick="displayContent('/DMS','S200507000009A','110202','A','F2109963');" onMouseOver="this.style.cursor='hand';">
需要提取的是onClick="displayContent('/DMS','S200507000009A','110201','A','F2109963');"和onClick="displayContent('/DMS','S200507000009A','110202','A','F2109963');" -----也是从onClick=到分号.
谢谢!分不够我再加!
9 个解决方案
#1
string strA ="<input type=\"radio\" name=\"selection\" onClick=\"selectData 'S200507000009A','','A','110201','Pre-test','WR','');\" onmouseover=\"this.style.cursor='hand';\"></td>";
Regex r =new Regex("onClick=\"[^\"]+\"");
// Match m =Regex.Match(strA,"onClick=\"[^\"]+\"");
Match m =r.Match(strA);
Regex r =new Regex("onClick=\"[^\"]+\"");
// Match m =Regex.Match(strA,"onClick=\"[^\"]+\"");
Match m =r.Match(strA);
#2
2种情况都是一样的,用上面的代码就可以取了
你用一个数组来存值.
string[] strsA =new string[m.Groups.Count];
for(int i=0;i<strsA.Length;i++)
strsA[i] =m.Groups[i].Value;
有分加最好了,呵呵,马上升2星
你用一个数组来存值.
string[] strsA =new string[m.Groups.Count];
for(int i=0;i<strsA.Length;i++)
strsA[i] =m.Groups[i].Value;
有分加最好了,呵呵,马上升2星
#3
楼上的兄弟...
你发的这个太考眼力了吧!
我整理整理先!
你发的这个太考眼力了吧!
我整理整理先!
#4
第一种的正则式:
string reg1="onClick=\"selectData.*\);";
第二种的正则式:
string reg1="onClick=\"displayContent.*\);";
//下面是匹配用的函数,inputstr为要抓数据的HTML,regstr为正则式,返回为匹配的字串数组.无匹配则返回NULL
public string[] reg(string inputstr, string regstr)
{
MatchCollection ms = Regex.Matches(inputstr, regstr);
if (ms.Count > 0)
{
string[] strs = new string[ms.Count];
for (int i = 0; i < ms.Count; i++)
{
strs[i] = ms[i].Value;
}
return strs;
}
return null;
}
string reg1="onClick=\"selectData.*\);";
第二种的正则式:
string reg1="onClick=\"displayContent.*\);";
//下面是匹配用的函数,inputstr为要抓数据的HTML,regstr为正则式,返回为匹配的字串数组.无匹配则返回NULL
public string[] reg(string inputstr, string regstr)
{
MatchCollection ms = Regex.Matches(inputstr, regstr);
if (ms.Count > 0)
{
string[] strs = new string[ms.Count];
for (int i = 0; i < ms.Count; i++)
{
strs[i] = ms[i].Value;
}
return strs;
}
return null;
}
#5
对了,上面那2种只是针对你给出的,如果人家把所有换行符都去掉或取消了某些换行,建议用下面的
第一种的正则式:
string reg1="onClick=\"selectData.*?\);";
第二种的正则式:
string reg1="onClick=\"displayContent.*?\);";
第一种的正则式:
string reg1="onClick=\"selectData.*?\);";
第二种的正则式:
string reg1="onClick=\"displayContent.*?\);";
#6
好像都不行呢? 我这样写的:
Dim m As Match = Regex.Match(html, "onClick=""selectData.*?\);""")
TextBox1.Text = m.Groups.Count
但是textbox1.text里显示的是1. 明明有很多的..
我干脆把大半部分的代码贴出来算了:
<input type="radio" name="selection" onClick="selectData
('S200507000009A','','A','110201','Pre-test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<td class="DataTR"><a onClick="displayContent
('/DMS','S200507000009A','110201','A','F2109963');"
onMouseOver="this.style.cursor='hand';"><font color="blue"><u>Pre-
test</u></font></a></td>
<input type="radio" name="selection" onClick="selectData
('S200507000009A','','A','110202','Basic Function test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<td class="DataTR"><a onClick="displayContent
('/DMS','S200507000009A','110202','A','F2109963');"
onMouseOver="this.style.cursor='hand';"><font color="blue"><u>Basic Function
test</u></font></a></td>
<input type="radio" name="selection" onClick="selectData
('S200507000009A','','A','120202','CPU/Memory Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051213022946','','','20051213022957',' 661M05-FX-6LS App Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051025052902','Game Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051025052909','O/S Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051025052914','NetBar Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051029014444','Performance test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<td class="DataTR"><a onClick="displayContent
('/DMS','D20051025052855','20051029014444','','F2109963');"
onMouseOver="this.style.cursor='hand';"><font color="blue"><u>Performance
test</u></font></a></td>
<input type="radio" name="selection" onClick="selectData
('D20060117051712','','','120206','Software compatibility test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20060117051712','','','120207','Performance and Game','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('S200509000108A','','A','120206','Software compatibility test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
还是提取onClick="selectData('S200507000009A','','A','110201','Pre-test','WR','');"
也就是从onClick=到引号.
和
onClick="displayContent('/DMS','S200507000009A','110201','A','F2109963');"
也是onClick=到引号.
Dim m As Match = Regex.Match(html, "onClick=""selectData.*?\);""")
TextBox1.Text = m.Groups.Count
但是textbox1.text里显示的是1. 明明有很多的..
我干脆把大半部分的代码贴出来算了:
<input type="radio" name="selection" onClick="selectData
('S200507000009A','','A','110201','Pre-test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<td class="DataTR"><a onClick="displayContent
('/DMS','S200507000009A','110201','A','F2109963');"
onMouseOver="this.style.cursor='hand';"><font color="blue"><u>Pre-
test</u></font></a></td>
<input type="radio" name="selection" onClick="selectData
('S200507000009A','','A','110202','Basic Function test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<td class="DataTR"><a onClick="displayContent
('/DMS','S200507000009A','110202','A','F2109963');"
onMouseOver="this.style.cursor='hand';"><font color="blue"><u>Basic Function
test</u></font></a></td>
<input type="radio" name="selection" onClick="selectData
('S200507000009A','','A','120202','CPU/Memory Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051213022946','','','20051213022957',' 661M05-FX-6LS App Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051025052902','Game Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051025052909','O/S Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051025052914','NetBar Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051029014444','Performance test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<td class="DataTR"><a onClick="displayContent
('/DMS','D20051025052855','20051029014444','','F2109963');"
onMouseOver="this.style.cursor='hand';"><font color="blue"><u>Performance
test</u></font></a></td>
<input type="radio" name="selection" onClick="selectData
('D20060117051712','','','120206','Software compatibility test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20060117051712','','','120207','Performance and Game','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('S200509000108A','','A','120206','Software compatibility test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
还是提取onClick="selectData('S200507000009A','','A','110201','Pre-test','WR','');"
也就是从onClick=到引号.
和
onClick="displayContent('/DMS','S200507000009A','110201','A','F2109963');"
也是onClick=到引号.
#7
Dim mc As System.Text.RegularExpressions.MatchCollection = Regex.Matches(html, "onClick=""selectData.*?\);""")
TextBox1.Text = mc.Count
这个测试下
====CSDN 小助手 V2.5 2006年1月18日发布====
CSDN小助手是一款脱离浏览器也可以访问Csdn论坛的软件
界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/11/05/523395.aspx
下载:http://szlawbook.com/csdnv2
TextBox1.Text = mc.Count
这个测试下
====CSDN 小助手 V2.5 2006年1月18日发布====
CSDN小助手是一款脱离浏览器也可以访问Csdn论坛的软件
界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/11/05/523395.aspx
下载:http://szlawbook.com/csdnv2
#8
Regex r =new Regex("onClick=\"[^\"]+\"");
MatchCollection mc =r.Matches(html);
string[] strsA =new string[mc.Count];
for(int i=0;i<strsA.Length;i++)
strsA[i] =mc[i].Groups[0].Value;
for(int i=0;i<strsA.Length;i++)
Console.WriteLine(mc[i].Groups[0].Value);
测试通过,可取全部数据
MatchCollection mc =r.Matches(html);
string[] strsA =new string[mc.Count];
for(int i=0;i<strsA.Length;i++)
strsA[i] =mc[i].Groups[0].Value;
for(int i=0;i<strsA.Length;i++)
Console.WriteLine(mc[i].Groups[0].Value);
测试通过,可取全部数据
#9
VB.NET下
Dim html = TextBox1.Text
Dim mc As MatchCollection = Regex.Matches(html, "onClick=""selectData\(.*?\);""")
TextBox1.Text = mc.Count
Dim i As Integer
For i = 0 To mc.Count - 1
TextBox2.Text = TextBox2.Text & mc.Item(i).Value.ToString
Next
测试通过:)
Dim html = TextBox1.Text
Dim mc As MatchCollection = Regex.Matches(html, "onClick=""selectData\(.*?\);""")
TextBox1.Text = mc.Count
Dim i As Integer
For i = 0 To mc.Count - 1
TextBox2.Text = TextBox2.Text & mc.Item(i).Value.ToString
Next
测试通过:)
#1
string strA ="<input type=\"radio\" name=\"selection\" onClick=\"selectData 'S200507000009A','','A','110201','Pre-test','WR','');\" onmouseover=\"this.style.cursor='hand';\"></td>";
Regex r =new Regex("onClick=\"[^\"]+\"");
// Match m =Regex.Match(strA,"onClick=\"[^\"]+\"");
Match m =r.Match(strA);
Regex r =new Regex("onClick=\"[^\"]+\"");
// Match m =Regex.Match(strA,"onClick=\"[^\"]+\"");
Match m =r.Match(strA);
#2
2种情况都是一样的,用上面的代码就可以取了
你用一个数组来存值.
string[] strsA =new string[m.Groups.Count];
for(int i=0;i<strsA.Length;i++)
strsA[i] =m.Groups[i].Value;
有分加最好了,呵呵,马上升2星
你用一个数组来存值.
string[] strsA =new string[m.Groups.Count];
for(int i=0;i<strsA.Length;i++)
strsA[i] =m.Groups[i].Value;
有分加最好了,呵呵,马上升2星
#3
楼上的兄弟...
你发的这个太考眼力了吧!
我整理整理先!
你发的这个太考眼力了吧!
我整理整理先!
#4
第一种的正则式:
string reg1="onClick=\"selectData.*\);";
第二种的正则式:
string reg1="onClick=\"displayContent.*\);";
//下面是匹配用的函数,inputstr为要抓数据的HTML,regstr为正则式,返回为匹配的字串数组.无匹配则返回NULL
public string[] reg(string inputstr, string regstr)
{
MatchCollection ms = Regex.Matches(inputstr, regstr);
if (ms.Count > 0)
{
string[] strs = new string[ms.Count];
for (int i = 0; i < ms.Count; i++)
{
strs[i] = ms[i].Value;
}
return strs;
}
return null;
}
string reg1="onClick=\"selectData.*\);";
第二种的正则式:
string reg1="onClick=\"displayContent.*\);";
//下面是匹配用的函数,inputstr为要抓数据的HTML,regstr为正则式,返回为匹配的字串数组.无匹配则返回NULL
public string[] reg(string inputstr, string regstr)
{
MatchCollection ms = Regex.Matches(inputstr, regstr);
if (ms.Count > 0)
{
string[] strs = new string[ms.Count];
for (int i = 0; i < ms.Count; i++)
{
strs[i] = ms[i].Value;
}
return strs;
}
return null;
}
#5
对了,上面那2种只是针对你给出的,如果人家把所有换行符都去掉或取消了某些换行,建议用下面的
第一种的正则式:
string reg1="onClick=\"selectData.*?\);";
第二种的正则式:
string reg1="onClick=\"displayContent.*?\);";
第一种的正则式:
string reg1="onClick=\"selectData.*?\);";
第二种的正则式:
string reg1="onClick=\"displayContent.*?\);";
#6
好像都不行呢? 我这样写的:
Dim m As Match = Regex.Match(html, "onClick=""selectData.*?\);""")
TextBox1.Text = m.Groups.Count
但是textbox1.text里显示的是1. 明明有很多的..
我干脆把大半部分的代码贴出来算了:
<input type="radio" name="selection" onClick="selectData
('S200507000009A','','A','110201','Pre-test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<td class="DataTR"><a onClick="displayContent
('/DMS','S200507000009A','110201','A','F2109963');"
onMouseOver="this.style.cursor='hand';"><font color="blue"><u>Pre-
test</u></font></a></td>
<input type="radio" name="selection" onClick="selectData
('S200507000009A','','A','110202','Basic Function test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<td class="DataTR"><a onClick="displayContent
('/DMS','S200507000009A','110202','A','F2109963');"
onMouseOver="this.style.cursor='hand';"><font color="blue"><u>Basic Function
test</u></font></a></td>
<input type="radio" name="selection" onClick="selectData
('S200507000009A','','A','120202','CPU/Memory Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051213022946','','','20051213022957',' 661M05-FX-6LS App Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051025052902','Game Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051025052909','O/S Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051025052914','NetBar Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051029014444','Performance test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<td class="DataTR"><a onClick="displayContent
('/DMS','D20051025052855','20051029014444','','F2109963');"
onMouseOver="this.style.cursor='hand';"><font color="blue"><u>Performance
test</u></font></a></td>
<input type="radio" name="selection" onClick="selectData
('D20060117051712','','','120206','Software compatibility test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20060117051712','','','120207','Performance and Game','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('S200509000108A','','A','120206','Software compatibility test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
还是提取onClick="selectData('S200507000009A','','A','110201','Pre-test','WR','');"
也就是从onClick=到引号.
和
onClick="displayContent('/DMS','S200507000009A','110201','A','F2109963');"
也是onClick=到引号.
Dim m As Match = Regex.Match(html, "onClick=""selectData.*?\);""")
TextBox1.Text = m.Groups.Count
但是textbox1.text里显示的是1. 明明有很多的..
我干脆把大半部分的代码贴出来算了:
<input type="radio" name="selection" onClick="selectData
('S200507000009A','','A','110201','Pre-test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<td class="DataTR"><a onClick="displayContent
('/DMS','S200507000009A','110201','A','F2109963');"
onMouseOver="this.style.cursor='hand';"><font color="blue"><u>Pre-
test</u></font></a></td>
<input type="radio" name="selection" onClick="selectData
('S200507000009A','','A','110202','Basic Function test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<td class="DataTR"><a onClick="displayContent
('/DMS','S200507000009A','110202','A','F2109963');"
onMouseOver="this.style.cursor='hand';"><font color="blue"><u>Basic Function
test</u></font></a></td>
<input type="radio" name="selection" onClick="selectData
('S200507000009A','','A','120202','CPU/Memory Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051213022946','','','20051213022957',' 661M05-FX-6LS App Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051025052902','Game Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051025052909','O/S Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051025052914','NetBar Test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20051025052855','','','20051029014444','Performance test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<td class="DataTR"><a onClick="displayContent
('/DMS','D20051025052855','20051029014444','','F2109963');"
onMouseOver="this.style.cursor='hand';"><font color="blue"><u>Performance
test</u></font></a></td>
<input type="radio" name="selection" onClick="selectData
('D20060117051712','','','120206','Software compatibility test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('D20060117051712','','','120207','Performance and Game','WR','');"
onmouseover="this.style.cursor='hand';"></td>
<input type="radio" name="selection" onClick="selectData
('S200509000108A','','A','120206','Software compatibility test','WR','');"
onmouseover="this.style.cursor='hand';"></td>
还是提取onClick="selectData('S200507000009A','','A','110201','Pre-test','WR','');"
也就是从onClick=到引号.
和
onClick="displayContent('/DMS','S200507000009A','110201','A','F2109963');"
也是onClick=到引号.
#7
Dim mc As System.Text.RegularExpressions.MatchCollection = Regex.Matches(html, "onClick=""selectData.*?\);""")
TextBox1.Text = mc.Count
这个测试下
====CSDN 小助手 V2.5 2006年1月18日发布====
CSDN小助手是一款脱离浏览器也可以访问Csdn论坛的软件
界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/11/05/523395.aspx
下载:http://szlawbook.com/csdnv2
TextBox1.Text = mc.Count
这个测试下
====CSDN 小助手 V2.5 2006年1月18日发布====
CSDN小助手是一款脱离浏览器也可以访问Csdn论坛的软件
界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/11/05/523395.aspx
下载:http://szlawbook.com/csdnv2
#8
Regex r =new Regex("onClick=\"[^\"]+\"");
MatchCollection mc =r.Matches(html);
string[] strsA =new string[mc.Count];
for(int i=0;i<strsA.Length;i++)
strsA[i] =mc[i].Groups[0].Value;
for(int i=0;i<strsA.Length;i++)
Console.WriteLine(mc[i].Groups[0].Value);
测试通过,可取全部数据
MatchCollection mc =r.Matches(html);
string[] strsA =new string[mc.Count];
for(int i=0;i<strsA.Length;i++)
strsA[i] =mc[i].Groups[0].Value;
for(int i=0;i<strsA.Length;i++)
Console.WriteLine(mc[i].Groups[0].Value);
测试通过,可取全部数据
#9
VB.NET下
Dim html = TextBox1.Text
Dim mc As MatchCollection = Regex.Matches(html, "onClick=""selectData\(.*?\);""")
TextBox1.Text = mc.Count
Dim i As Integer
For i = 0 To mc.Count - 1
TextBox2.Text = TextBox2.Text & mc.Item(i).Value.ToString
Next
测试通过:)
Dim html = TextBox1.Text
Dim mc As MatchCollection = Regex.Matches(html, "onClick=""selectData\(.*?\);""")
TextBox1.Text = mc.Count
Dim i As Integer
For i = 0 To mc.Count - 1
TextBox2.Text = TextBox2.Text & mc.Item(i).Value.ToString
Next
测试通过:)