How to get number if same keyword

For example:

FOR ID 12335 is matched with the ID 3456

If I used regex to get the first ID 12335 I am getting the output along with second id 3356
Since both has ID as keyword how to resolve this

Hi!

When you’re using Regex.Match you get all the matches for your pattern.
Just fetch the first match?

Match = Regex.Match(input, pattern)
First Match= match.Groups(1).Value

Hi @sruthesanju

Try this

System.Text.RegularExpressions.Regex.Matches(Input,"(?<=ID\s+)\d+").First.ToString

Regards,

1 Like

System.Text.RegularExpresdioms.Regex.Matcjes(Input,“?<=ID\s+)\d+”, System.Text.RegularExpression.RegexOptions.Multiline).cast(of system.text.RegukarExpressions.Match). Select (Function (X) dt.Rows.Add(X.tostring().Trim())). CopyToDataTable()

How to modify this god for same keyword

@sruthesanju

Can you please explain brief what you want

Regards,

I need to modify this code for same keyword here I have used keyword ID but I got 2 IDs in same datatable 12335 and 3356

but I need to get first ID in one data table and remaining id in another datatable