日期:2014-05-17 浏览次数:21010 次
<% dim str str="<IMG src='/UploadFile/11.jpg' border=0> <IMG src='/UploadFile/232.jpg' border=0> <IMG src='/UploadFile/4112.jpg' border=0>" myarry=split(str,"'") response.write("img1="&myarry(1)&"&img2="&myarry(3)&"&img3="&myarry(5))&"&" %>
------解决方案--------------------
Function GetImgs(str) Dim a(), regex, i, matches, match Set regex = New RegExp regex.Pattern = "<img src\=""([^""]+)"" border=0>" regex.IgnoreCase = True regex.Global = True Set matches = regex.Execute(str) ReDim a(matches.Count-1) For i = 0 To matches.Count - 1 a(i) = "img" & (i+1) & "=" & matches(i).Submatches(0) Next Set matches = Nothing Set regex = Nothing GetImgs = Join(a, "&") End Function Dim str str = "<IMG src=""/UploadFile/11.jpg"" border=0><IMG src=""/UploadFile/232.jpg"" border=0><IMG src=""/UploadFile/4112.jpg"" border=0>" Response getImgs(str)
------解决方案--------------------
dim str str="<IMG src=""/UploadFile/11.jpg"" border=0> <IMG src=""/UploadFile/232.jpg"" border=0> <IMG src=""/UploadFile/4112.jpg"" border=0>" ar=split(str,"""") str2 = "" For i = 0 To UBound(ar) If InStr(ar(i),"/UploadFile/")>0 Then If str2 = "" Then str2 = ar(i) Else str2 = str2 & "," & ar(i) End If End If next response.write str2
------解决方案--------------------
我说LZ,现在你给我的是一串字符,放到程序里去肯定要改一下引号,不然怎么用?
如果你的一串字符是人工输的,就可以人工改,如果是从数据库里调出来的就不同了
------解决方案--------------------
<IMG src="/UploadFile/11.jpg" border=0>
使用replace将<IMG src="和" border=0>替换为空就行了
------解决方案--------------------
Dim input, output, i input = "<IMG src=""/UploadFile/11.jpg"" border=0> <IMG src=""/UploadFile/232.jpg"" border=0> <IMG src=""/UploadFile/4112.jpg"" border=0> " Dim re, m Set re = new Regexp re.pattern = "<img\s+src=""([^""]+)" re.IgnoreCase = True re.Global = True Set m = re.Execute(input) For i = 0 To m.count-1 output = output & "img" & i+1 & "=" & m(i).Submatches(0) & "&" Next Response.Write "<script language='javascript'>alert('" & output & "');</script>" Set re = Nothing Set m = Nothing