源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

VBS教程:对象-正则表达式(RegExp)对象

  • 时间:2022-02-07 16:14 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:VBS教程:对象-正则表达式(RegExp)对象

正则表达式(RegExp)对象

提供简单的正则表达式支持功能。 [h3]说明[/h3]下面的代码说明了[b]RegExp[/b]对象的用法:
[code]Function RegExpTest(patrn, strng)  Dim regEx, Match, Matches      ' [/code]建立变量。[code]  Set regEx = New [b]RegExp[/b][/code]         [code]' [/code]建立正则表达式。[code]  regEx.Pattern = patrn         ' [/code]设置模式。[code]  regEx.IgnoreCase = True         ' [/code]设置是否区分字符大小写。[code]  regEx.Global = True         ' [/code]设置全局可用性。[code]  Set Matches = regEx.Execute(strng)   ' [/code]执行搜索。[code]  For Each Match in Matches      ' [/code]遍历匹配集合。[code]    RetStr = RetStr & "Match found at position "[/code][code]    RetStr = RetStr & Match.FirstIndex & ". Match Value is '"[/code][code]    RetStr = RetStr & Match.Value & "'." & vbCRLF[/code][code]  Next[/code][code]  RegExpTest = RetStr[/code][code]End Function[/code][code]MsgBox(RegExpTest("is.", "IS1 is2 IS3 is4"))[/code]
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部