Regex to extract part of the text, Please advice

Hello dear friends.

I Need your support:
I have this code: GLAGAC512BOEFOG"

image

I need to extract the three numbers and the three letters before: GAC512
Please advice how to do it:

Also would be great if you show me how to generate an array of all these codes from the datatable.

I also dont understand the format of this record:
image

Its so annyoing.

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"\D{3}\d{3}(?=\D|$)").Value

Regards,

1 Like

Works Perfectly.

Can you show me please how to generate an array of all these codes from the datatable column, or should i go with a for each loop and add to the array one by one ?
Thank you Yoichi

Hi,

Can you try the following LINQ expression?

arrString = ExtractDataTable.AsEnumerable.Select(Function(r) System.Text.RegularExpressions.Regex.Match(r(1).ToString,"\D{3}\d{3}(?=\D|$)").Value).ToArray

Hope this helps you.

Regards,

2 Likes

Hi,

Oh, sorry. r(1) should be r("Flight")

Regards,

1 Like

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