当前位置: 编程技术>其它
计算一个字符串在另一字符串中出现的次数函数
来源: 互联网 发布时间:2014-10-14
本文导语: Function strnum(patrn, strng) Dim regEx, Match, Matches,xx xx=0 Set regEx = New RegExp regEx.Pattern = patrn regEx.IgnoreCase = True ' 设置是否区分大小写。 regEx.Global = True Set Matches = regEx.Execute(strng) ...
Function strnum(patrn, strng)
Dim regEx, Match, Matches,xx
xx=0
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True ' 设置是否区分大小写。
regEx.Global = True
Set Matches = regEx.Execute(strng)
For Each Match in Matches
xx=xx+1
Next
strnum = xx
End Function
Dim regEx, Match, Matches,xx
xx=0
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True ' 设置是否区分大小写。
regEx.Global = True
Set Matches = regEx.Execute(strng)
For Each Match in Matches
xx=xx+1
Next
strnum = xx
End Function