<script language ="vbs">
Function RegExpTest(strng, patrn, patrn2)
Dim regEx, Match, Matches Set regEx =New RegExp regEx.IgnoreCase =True regEx.Global =True patrn = Split(patrn,"|")
ForEach p in patrn
regEx.Pattern = p strng = regEx.Replace(strng,"||"& Chr(10)& p)
Next
strng = Split(strng,"||")
ForEach E in strng
s = s + E + arrArt(patrn2)
Next
RegExpTest = s
EndFunction
Function arrArt(patrn2)
arrArti = Split(patrn2,"|")
Randomize
arrArt = arrArti(CInt(UBound(arrArti)* Rnd))
EndFunction
strng ="111<br/>222</p>333<br/>444</p>555<Br>666</P>111"
Source = strng
patrn ="<br/>|</p>|<br>"
patrn2 ="www.cbdcn.com|http://www.yongfa365.com/blog|hi.baidu.com/yongfa365"
words = RegExpTest(strng, patrn, patrn2)
MsgBox(words)
</script>
<script>
document.Write "<fieldset><legend>原字符串</legend>"+ Source +"</fieldset><br>"
document.Write "<fieldset><legend>转换后字符串</legend>"+ words +"</fieldset><br>"
</script>
引用本页地址:
http://www.yongfa365.com/item/0046b03419ad59dc.html