用户登录
用户注册

分享至

VBS教程:VBscript属性-FirstIndex 属性

  • 作者: 闹够了没有wait
  • 来源: 51数据库
  • 2021-09-04

firstindex 属性

返回在搜索字符串中匹配的位置。

object.firstindex

object 参数总是一个 match 对象。

说明

firstindex 属性使用从零起算的偏移量,该偏移量是相对于搜索字符串的起始位置而言的。换言之,字符串中的第一个字符被标识为字符 0。 下面的例子说明了 firstindex 属性的用法:

~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 & "匹配 " & i & " 位于 "    retstr = retstr & match.firstindex & ". match value is "'    retstr = retstr & match.value & "'." & vbcrlf  next  regexptest = retstrend functionmsgbox(regexptest("is.", "is1 is2 is3 is4"))
软件
前端设计
程序设计
Java相关