使用正则表达式取出文章内容所有图片路径的方法
Function RegExpTest(patrn, strng) Dim regEx,Match,Matches Set regEx = New RegExp regEx.Pattern = patrn regEx.IgnoreCase = true regEx.Global = True Set Matches = regEx.Execute(strng) For Each Match in Matches RetStr = RetStr & Match.Value & "," Next RegExpTest = RetStr End Function
Function RegExpReplace(patrn,strng) dim re set re=new Regexp re.Pattern=patrn re.ignoreCase=true re.Global =true re.pattern="<img.*?\s+src=([""'])?([^""']*)([""'\s])+.*?>" RegExpReplace=re.replace(strng,"$2") End Function
str="aaaaa<img border=""0"" src=""music/en/0052.jpg"" width=""100"" height=""100"">sssssssss<img border=""0"" src=""music/en/0053.jpg"" width=""100"" height=""100"">aaaaaa" str=RegExpTest("<img.*?\s+src=([""'])?([^""']*)([""'\s])+.*?>",str) response.write RegExpReplace("<img.*?\s+src=([""'])?([^""']*)([""'\s])+.*?>",str)
飞飞As.p技术乐园
|