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

源码网商城

VBS教程:VBscript属性-FirstIndex 属性

  • 时间:2021-05-07 23:39 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:VBS教程:VBscript属性-FirstIndex 属性

FirstIndex 属性

返回在搜索字符串中匹配的位置。 [code][i]object[/i].[b]FirstIndex[/b][/code] [i]object[/i] 参数总是一个 [b]Match[/b] 对象。 [h3]说明[/h3][b]FirstIndex[/b] 属性使用从零起算的偏移量,该偏移量是相对于搜索字符串的起始位置而言的。换言之,字符串中的第一个字符被标识为字符 0。 下面的例子说明了 [b]FirstIndex[/b] 属性的用法:
[code]~Function RegExpTest(patrn, strng)  Dim regEx, Match, Matches[/code]         [code]' [/code]建立变量。[code]  Set regEx = New RegExp[/code]         [code]' [/code]建立正则表达式。[code]  regEx.Pattern = patrn[/code]         [code]' [/code]设置模式。[code]  regEx.IgnoreCase = True[/code]         [code]' [/code]设置是否区分大小写。[code]  regEx.Global = True[/code]            [code]' [/code]设置全局可用性。[code]  Set Matches = regEx.Execute(strng)[/code]      [code]' [/code]执行搜索。[code]  For Each Match in Matches[/code]         [code]' [/code]遍历[code] Matches [/code]集合。[code]    RetStr = RetStr & "[/code]匹配[code] " & I & " [/code]位于[code] "[/code][code]    RetStr = RetStr & [b]Match.FirstIndex[/b] & ". 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
微信版

扫一扫进微信版
返回顶部