SoFunction
Updated on 2025-04-10

VBS tutorial: VBscript attribute-FirstIndex attribute

FirstIndex Properties

Returns the matching position in the search string.

object.FirstIndex

objectAlways a parameterMatchObject.

illustrate

FirstIndexThe property uses an offset calculated from zero, which is relative to the starting position of the search string. In other words, the first character in the string is identified as character 0. The following example illustratesFirstIndexUsage of attributes:

~Function RegExpTest(patrn, strng)  Dim regEx, Match, Matches         ' Create variables。  Set regEx = New RegExp         ' Create regular expressions。   = patrn         ' Set mode。   = True         ' Set whether it is case sensitive。   = True            ' Set global availability。  Set Matches = (strng)      ' Perform a search。  For Each Match in Matches         ' Traversal Matches gather。    RetStr = RetStr & "match " & I & " lie in "    RetStr = RetStr &  & ". Match Value is "'    RetStr = RetStr &  & "'." & vbCRLF  Next  RegExpTest = RetStrEnd FunctionMsgBox(RegExpTest("is.", "IS1 is2 IS3 is4"))