专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »编程综合 » 正则函数:asp match正则函数使用Matchs例子 »正文

正则函数:asp match正则函数使用Matchs例子

来源: 发布时间:星期日, 2009年9月6日 浏览:76次 评论:0

介绍说明
Match 对象只能通过 RegExp 对象 Execute 思路方法来创建该思路方法实际上返回了 Match 对象集合所有 Match 对象属性都是只读
在执行正则表达式时可能产生零个或多个 Match 对象每个 Match 对象提供了被正则表达式搜索找到访问、长度以及找到匹配索引位置等
下面代码介绍说明了 Match 对象使用方法:
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 " & I & " found at position "
RetStr = RetStr & Match.FirstIndex & ". Match Value is "'
RetStr = RetStr & Match.Value & "'." & vbCRLF
Next
RegExpTest = RetStr
End Function
MsgBox(RegExpTest("is.", "IS1 is2 IS3 is4"))
0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: