0514-86177077
9:00-17:00(工作日)
返回在搜索字符串中匹配的位置。
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"))
~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 = RetStr
End Function
MsgBox(RegExpTest("is.", "IS1 is2 IS3 is4"))
標簽:丹東 南京 鶴壁 內蒙古 達州 資質掛靠 柳州 張掖
上一篇:VBS教程:VBscript屬性-Global 屬性
下一篇:VBS教程:VBscript屬性-Description 屬性
Copyright ? 1999-2012 誠信 合法 規范的巨人網絡通訊始建于2005年
蘇ICP備15040257號-8