<Script language = "vbs">
'Function name: regexptest
'Parameter: strng -- the string to be processed; Various ending signs separated by | in patrn --, such as: <br/>|</P> | <br>; patrn2 -- the string to be replaced with, also |
Open
'Author: Liu yongfa (yongfa365) 'blog
'Function: Randomly Add the content in patrn2 to the end of the character in the strng string
Function regexptest (strng, patrn, patrn2)
Dim RegEx, match, matches 'to create a variable.
Set RegEx = new Regexp 'to create a regular expression.
RegEx. ignorecase = true' specifies whether the characters are case sensitive.
RegEx. Global = true' to set global availability.
Patrn = Split (patrn, "| ")
Foreach P in patrn
RegEx. pattern = P' setting mode.
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.xiaoshuo8.net | http://www.jb51.net/blog | hi.baidu.com /"
Words = regexptest (strng, patrn, patrn2)
Msgbox (words)
</SCRIPT>
<SCRIPT>
Document. Write "<fieldset> <legend> original string </legend>" + Source + "</fieldset> <br>"
Document. Write "<fieldset> <legend> converted string </legend>" + words + "</fieldset> <br>"
</SCRIPT>