'将原来的值替换为新值
Function ReplaceTest(sourcestr,patrn,replStr)
Dim regEx,str1,Match,Matches ' 建立变量。
str1 = sourcestr
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = True ' 设置是否区分大小写。
regEx.Global = True '设置全局可用性
ReplaceTest = regEx.Replace(str1, replStr) ' 作替换。
End Function
Function ReplaceTest(sourcestr,patrn,replStr)
Dim regEx,str1,Match,Matches ' 建立变量。
str1 = sourcestr
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = True ' 设置是否区分大小写。
regEx.Global = True '设置全局可用性
ReplaceTest = regEx.Replace(str1, replStr) ' 作替换。
End Function
'使用
str=ReplaceTest((sourcestr,"f*","h")
'查找content字段中的图片文件路径,将得到的结果存到数组里
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) '执行搜索。
dim fileArray(15),i
i=0
For Each Match in Matches '遍历匹配集合。
TempStr = Match.Value
TempStr=left(TempStr,(instr(TempStr,chr(34))-1))
fileArray(i) =TempStr
i=i+1
if(i>=15) then
exit for
end if
Next
RegExpTest = fileArray
End Function
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) '执行搜索。
dim fileArray(15),i
i=0
For Each Match in Matches '遍历匹配集合。
TempStr = Match.Value
TempStr=left(TempStr,(instr(TempStr,chr(34))-1))
fileArray(i) =TempStr
i=i+1
if(i>=15) then
exit for
end if
Next
RegExpTest = fileArray
End Function
说明:asp里数组要初始化大小