code="sdfgsdfg<a href=http://www.cnread.net/cnread1/jjzp/l/lys/jjzz/012.htm onmousedown=""return clk(this,'res',5)"" target=_blank> wersdfgsdgeeeeeeeeeedfgdf"
Set regEx = New RegExp
re="(?=<a href="&url&".* onmousedown=""return clk\(this,'res',)(\d+)(?=\)"" target=_blank>)"
regEx.Pattern = re
regEx.IgnoreCase = False
set Matches = regEx.Execute(code)
response.Write(Matches.count)
For Each Match in Matches
RegExpTest = RegExpTest & Match.Value & "," & vbCRLF
Next
response.Write("数字:")
response.Write(RegExpTest)
5 个解决方案
#1
<script>
var code='sdfgsdfg<a href=http://www.cnread.net/cnread1/jjzp/l/lys/jjzz/012.htm onmousedown="return clk(this,\'res\',5)" target=_blank> wersdfgsdgeeeeeeeeeedfgdf';
code=code.match(/return.+?,\d\)/g)[0];
alert(code.replace(/[^\d]/g,''));
</script>
var code='sdfgsdfg<a href=http://www.cnread.net/cnread1/jjzp/l/lys/jjzz/012.htm onmousedown="return clk(this,\'res\',5)" target=_blank> wersdfgsdgeeeeeeeeeedfgdf';
code=code.match(/return.+?,\d\)/g)[0];
alert(code.replace(/[^\d]/g,''));
</script>
#2
此法不行,因为本意是查找这个联结所对应的数字, 如这样就把所有连接所对应的数字都找出来了.
即查找的地方为
<a href=http://www.cnread.net/ onmousedown="return clk(this,'res',5)" target=_blank>
<a href=http://www.aaaa.net/ onmousedown="return clk(this,'res',6)" target=_blank>
<a href=http://www.bbbb.net/ onmousedown="return clk(this,'res',7)" target=_blank>
我想找到www.cnread.net所对应的数字.
即查找的地方为
<a href=http://www.cnread.net/ onmousedown="return clk(this,'res',5)" target=_blank>
<a href=http://www.aaaa.net/ onmousedown="return clk(this,'res',6)" target=_blank>
<a href=http://www.bbbb.net/ onmousedown="return clk(this,'res',7)" target=_blank>
我想找到www.cnread.net所对应的数字.
#3
没人知道吗?
#4
assume you are using ASP + VBScript, try
<%
url = "www.cnread.net"
'code="sdfgsdfg<a href=http://www.cnread.net/cnread1/jjzp/l/lys/jjzz/012.htm onmousedown=""return clk(this,'res',5)"" target=_blank> wersdfgsdgeeeeeeeeeedfgdf"
code = "<a href=http://www.cnread.net/ onmousedown=""return clk(this,'res',5)"" target=_blank><a href=http://www.aaaa.net/ onmousedown=""return clk(this,'res',6)"" target=_blank> <a href=http://www.cnread.net/ onmousedown=""return clk(this,'res',7)"" target=_blank>"
Set regEx = New RegExp
re="<a href=\s*\S*" & url & "\S*\s*onmousedown=""return clk\(this\s*,\s*'res'\s*,\s*(\d+)\s*\)""[^>]*>"
regEx.Pattern = re
regEx.IgnoreCase = true
regEx.Global = true
set Matches = regEx.Execute(code)
'response.Write(Matches.count)
For Each Match in Matches
RegExpTest = RegExpTest & Match.SubMatches(0) & "," & vbCRLF
Next
response.Write(RegExpTest)
%>
<%
url = "www.cnread.net"
'code="sdfgsdfg<a href=http://www.cnread.net/cnread1/jjzp/l/lys/jjzz/012.htm onmousedown=""return clk(this,'res',5)"" target=_blank> wersdfgsdgeeeeeeeeeedfgdf"
code = "<a href=http://www.cnread.net/ onmousedown=""return clk(this,'res',5)"" target=_blank><a href=http://www.aaaa.net/ onmousedown=""return clk(this,'res',6)"" target=_blank> <a href=http://www.cnread.net/ onmousedown=""return clk(this,'res',7)"" target=_blank>"
Set regEx = New RegExp
re="<a href=\s*\S*" & url & "\S*\s*onmousedown=""return clk\(this\s*,\s*'res'\s*,\s*(\d+)\s*\)""[^>]*>"
regEx.Pattern = re
regEx.IgnoreCase = true
regEx.Global = true
set Matches = regEx.Execute(code)
'response.Write(Matches.count)
For Each Match in Matches
RegExpTest = RegExpTest & Match.SubMatches(0) & "," & vbCRLF
Next
response.Write(RegExpTest)
%>
#5
thanks saucer(思归)
原来 用SubMatches可以获取到
原来 用SubMatches可以获取到
#1
<script>
var code='sdfgsdfg<a href=http://www.cnread.net/cnread1/jjzp/l/lys/jjzz/012.htm onmousedown="return clk(this,\'res\',5)" target=_blank> wersdfgsdgeeeeeeeeeedfgdf';
code=code.match(/return.+?,\d\)/g)[0];
alert(code.replace(/[^\d]/g,''));
</script>
var code='sdfgsdfg<a href=http://www.cnread.net/cnread1/jjzp/l/lys/jjzz/012.htm onmousedown="return clk(this,\'res\',5)" target=_blank> wersdfgsdgeeeeeeeeeedfgdf';
code=code.match(/return.+?,\d\)/g)[0];
alert(code.replace(/[^\d]/g,''));
</script>
#2
此法不行,因为本意是查找这个联结所对应的数字, 如这样就把所有连接所对应的数字都找出来了.
即查找的地方为
<a href=http://www.cnread.net/ onmousedown="return clk(this,'res',5)" target=_blank>
<a href=http://www.aaaa.net/ onmousedown="return clk(this,'res',6)" target=_blank>
<a href=http://www.bbbb.net/ onmousedown="return clk(this,'res',7)" target=_blank>
我想找到www.cnread.net所对应的数字.
即查找的地方为
<a href=http://www.cnread.net/ onmousedown="return clk(this,'res',5)" target=_blank>
<a href=http://www.aaaa.net/ onmousedown="return clk(this,'res',6)" target=_blank>
<a href=http://www.bbbb.net/ onmousedown="return clk(this,'res',7)" target=_blank>
我想找到www.cnread.net所对应的数字.
#3
没人知道吗?
#4
assume you are using ASP + VBScript, try
<%
url = "www.cnread.net"
'code="sdfgsdfg<a href=http://www.cnread.net/cnread1/jjzp/l/lys/jjzz/012.htm onmousedown=""return clk(this,'res',5)"" target=_blank> wersdfgsdgeeeeeeeeeedfgdf"
code = "<a href=http://www.cnread.net/ onmousedown=""return clk(this,'res',5)"" target=_blank><a href=http://www.aaaa.net/ onmousedown=""return clk(this,'res',6)"" target=_blank> <a href=http://www.cnread.net/ onmousedown=""return clk(this,'res',7)"" target=_blank>"
Set regEx = New RegExp
re="<a href=\s*\S*" & url & "\S*\s*onmousedown=""return clk\(this\s*,\s*'res'\s*,\s*(\d+)\s*\)""[^>]*>"
regEx.Pattern = re
regEx.IgnoreCase = true
regEx.Global = true
set Matches = regEx.Execute(code)
'response.Write(Matches.count)
For Each Match in Matches
RegExpTest = RegExpTest & Match.SubMatches(0) & "," & vbCRLF
Next
response.Write(RegExpTest)
%>
<%
url = "www.cnread.net"
'code="sdfgsdfg<a href=http://www.cnread.net/cnread1/jjzp/l/lys/jjzz/012.htm onmousedown=""return clk(this,'res',5)"" target=_blank> wersdfgsdgeeeeeeeeeedfgdf"
code = "<a href=http://www.cnread.net/ onmousedown=""return clk(this,'res',5)"" target=_blank><a href=http://www.aaaa.net/ onmousedown=""return clk(this,'res',6)"" target=_blank> <a href=http://www.cnread.net/ onmousedown=""return clk(this,'res',7)"" target=_blank>"
Set regEx = New RegExp
re="<a href=\s*\S*" & url & "\S*\s*onmousedown=""return clk\(this\s*,\s*'res'\s*,\s*(\d+)\s*\)""[^>]*>"
regEx.Pattern = re
regEx.IgnoreCase = true
regEx.Global = true
set Matches = regEx.Execute(code)
'response.Write(Matches.count)
For Each Match in Matches
RegExpTest = RegExpTest & Match.SubMatches(0) & "," & vbCRLF
Next
response.Write(RegExpTest)
%>
#5
thanks saucer(思归)
原来 用SubMatches可以获取到
原来 用SubMatches可以获取到