'格式化字符串
function strformat(str)
strformat=str
Dim regEx, Match, Matches ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = "["&vbcrlf&"]+" ' 设置模式。
regEx.IgnoreCase = True ' 设置是否区分字符大小写。
regEx.Global = True ' 设置全局可用性。
Set Matches = regEx.Execute(str) ' 执行搜索
For Each Match in Matches ' 遍历匹配集合。
strformat = replace(strformat,Match.Value,"<br/>")
Next
end function
function strformat(str)
strformat=str
Dim regEx, Match, Matches ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = "["&vbcrlf&"]+" ' 设置模式。
regEx.IgnoreCase = True ' 设置是否区分字符大小写。
regEx.Global = True ' 设置全局可用性。
Set Matches = regEx.Execute(str) ' 执行搜索
For Each Match in Matches ' 遍历匹配集合。
strformat = replace(strformat,Match.Value,"<br/>")
Next
end function
以上函数利用正侧表达式将多个连续的回车换行替换成一个<br/>