首页 > 编程 > Regex > 正文

计算一个字符串在另一字符串中出现的次数函数

2020-03-16 21:19:26
字体:
来源:转载
供稿:网友

计算一个字符串在另一字符串中出现的次数函数

Functionstrnum(patrn,strng)

DimregEx,Match,Matches,xx

xx=0

SetregEx=NewRegExp

regEx.Pattern=patrn

regEx.IgnoreCase=True'设置是否区分大小写。

regEx.Global=True

SetMatches=regEx.Execute(strng)

ForEachMatchinMatches

xx=xx+1

Next

strnum=xx

EndFunction

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表