I need to get the index position value of submatched string. As per documentation, I have read through this Regular expression and got to know FirstIndex
property to get the position of matched string.
But this works only for one dimensional matched string. I couldn't apply FirstIndex
for submatches.
Pls refer sample matches
I tried this format,
Dim myRegExp As Object, match As MatchCollection
Dim matched As String
Set myRegExp = CreateObject("VBScript.RegExp")
myRegExp.pattern = find
If myRegExp.test(text) = True Then
Set match = myRegExp.Execute(text)
Debug.Print match(0).submatches(0) '' this is matched string
Where should I call FirstIndex
to get position of submatched string
output:
match(0)=>Berry, Brent. (2006). What accounts for race and ethnic differences in Berry,
Brent. parental financial transfers to adult children in the United States? Journal of Family
Issues 37:1583-1604.
submatches(0)=>Berry, Brent.
submatches(6)=>2006
EXPECTED OUTPUT:
submatches(0) at 0th position
submatches(6) at 16th position and so on