How to Extract Regex Match n group n diynamicly

Hi Team,

I need to extract the value from a string which is Match 1 Group 1 and Match 2 Group 1

could some one share me the code

it could be like (“Regex.Match(outputPDF,”((.*\n){3})Director").match(0).Groups(1).Value

Thank you

Hi @Tharusha.fernando

Set Counter =1

use do while loop and

use the Expression and pass the counter value in Matches(Counter)

Set Counter= counter+1

Do while condition break using how much it want to iterate

Regards

Hi @pravin_calvin

if i need to get the value in the Match 1 group 1 how should my code should change

Thank you

Hi @Tharusha.fernando

Clarification need on that do you need to iterate Matches and Groups Simultaneouly or Matches only Or group only!

Regards

1 Like

Hi,

Can you try the following expression?

resultArray = System.Text.RegularExpressions.Regex.Matches(yourString,yourPattern).Cast(Of System.Text.RegularExpressions.Match).Select(Function(m) m.Groups(1).Value).ToArray

Regards,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.