Regex Question

  • Thread starter Thread starter JM
  • Start date Start date
J

JM

Hi,

I need to use "named groups" that are nested inside othe named grup, that
is:

strRegex="((?<BigGroup1>(?<value1>\d+) G1
(?<value2>))|(?<BigGroup2>(?<value1>\d+) Z))"

Example Text: "2354523 G1 74"
"132433222 G1 34"
"3455 Z"
"43543554 G1 3"

So in that case I like to obtain:
BigGroup1 success: Value1: 2354... Value2:74
BigGroup1 success: Value1: 132... Value2:344
BigGroup2 success: Value1: 3455
BigGroup1 success: Value1: 4354... Value2:3

My Question:

How I called a named group nested inside a second named group, That is how i
retrieve the value of Value2 inside BigGroup1?, I have tried:

if maMatch.groups("BigGroup1").success then
value2=mamatch.groups("BigGroup1").groups("value2").tostring <- but it
seems this do not works
endif

Thanks,

Jaime
 
If maMatch.Groups("BigGroup1").Success Then
value1 = maMatch.Groups("value1").ToString
value2 = maMatch.Groups("value2").ToString
Debug.WriteLine(value1)
Debug.WriteLine(value2)
ElseIf maMatch.Groups("BigGroup2").Success Then
value1 = maMatch.Groups("value1").ToString
Debug.WriteLine(value1)
End If
 
Back
Top