Renvoie la longueur d'une correspondance trouvée dans une chaîne de recherche.
object.Length
L'argument object représente toujours un objet Match.
Le code suivant montre comment utiliser la propriété Length :
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' Crée la variable.
Set regEx = New RegExp ' Crée l'expression régulière.
regEx.Pattern = patrn ' Définit les critères.
regEx.IgnoreCase = True ' Ignore la casse.
regEx.Global = True ' Définit le champ d'application.
Set Matches = regEx.Execute(strng) ' Lance la recherche.
For Each Match in Matches ' Itère la collection Matches.
RetStr = RetStr & "Correspondance " & I & " trouvée à la position "
RetStr = RetStr & Match.FirstIndex & ". La longueur de correspondance est "
RetStr = RetStr & Match.Length
RetStr = RetStr & " caractères." & vbCRLF
Next
RegExpTest = RetStr
End Function
MsgBox(RegExpTest("est.", "IS1 is2 IS3 is4"))
FirstIndex, propriété | Value, propriété
Application : Match, objet