str="<P>1</P><P>2</P><P>3</P><P>4</P>"
patrn="<\/P>"
i=0
do while RegExp_Test(patrn,str)=true
str=RegExp_Replace(patrn,str,"</P><br>")
i=i+1
loop
Function RegExp_Test(patrn, strng)
Dim regEx
Dim matches
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = true' 设置是否区分字符大小写。
regEx.Global = True ' 设置全局可用性。
matches = regEx.test(strng)
RegExp_Test = matches
End Function
Function RegExp_Replace(patrn,str,replStr)
Dim regEx ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = true ' 设置是否区分大小写。
RegExp_Replace = regEx.Replace(str,replStr) ' 作替换。
End Function