当前位置: 移动技术网 > IT编程>脚本编程>VBScript > VBS教程:对象-Matches 集合

VBS教程:对象-Matches 集合

2017年12月12日  | 移动技术网IT编程  | 我要评论

新西兰现在时间,防脱生发,杀伐曲txt

matches 集合

正则表达式 match 对象的集合。

说明

matches 集合中包含若干独立的 match 对象,只能使用 regexp 对象的 execute 方法来创建之。与独立的 match 对象属性相同,matches `集合的一个属性是只读的。

在执行正则表达式时,可能产生零个或多个 match 对象。每个 match 对象都提供了与正则表达式匹配的字符串的访问入口、字符串的长度,以及标识匹配位置的索引。

下面的代码将说明如何使用正则表达式查找获得 matches 集合,以及如何循环遍历集合:

function regexptest(patrn, strng)  dim regex, match, matches      ' 创建变量。  set regex = new regexp         ' 创建正则表达式。  regex.pattern = patrn         ' 设置模式。  regex.ignorecase = true         ' 设置是否区分大小写。  regex.global = true         ' 设置全程匹配。  set matches = regex.execute(strng)   ' 执行搜索。  for each match in matches      ' 循环遍历matches集合。    retstr = retstr & "match found at position "    retstr = retstr & match.firstindex & ". match value is '"    retstr = retstr & match.value & "'." & vbcrlf  next  regexptest = retstrend functionmsgbox(regexptest("is.", "is1 is2 is3 is4"))

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网