Regex Regular Expression

hai, i need help with my regular expression for matches. i have this text.

“KUL AIR… CARGO ULD-MAWB-HAWB
1 BULK 756.00
TRANSIT
160-3917213 47 /303 * 239.00 PEN HKG CONSOLIDATION SPX
T1 TRM CX
160-3931724 91 /247 * 517.00 PEN HKG CONSOLIDATION SPX
T1 TRM CX
Sub Total 138 756.00
2 PMC05403R7 2,720.00
TRANSIT
160-3891814 1 /3 * 2,460.00 PEN ATL CONSOLIDATION BUP,SPX
T1 INT/TRM CX
Sub Total 1 2,460.00
3 PMC39868R7 2,720.00
TRANSIT
160-8913814 1 /3 * 2,460.00 PEN ATL CONSOLIDATION BUP,SPX
T1 INT/TRM CX
Sub Total 1 2,460.00”

if you can see, there are running numbers. 1 2 and 3. so I need to extract from number 1 until the numbers after sub total before number 2. then from number 2 until the numbers after sub total before number 3. the line between the number and sub total is different.

i only can get until this expression \b([\d]{1})\s([A-Z]{3,4})(.)\n([A-Z]+) . i dont know how to continue . please help . thank you

Hi,

Can you try the following?

System.Text.RegularExpressions.Regex.Matches(s,"\d+\s[\s\S]*?Sub Total.*")

Main.xaml (7.8 KB)

Regards,

it works ! thank you so much

1 Like

Hi,

Sorry, but in some cases, the above might not work. So the following might be better.

System.Text.RegularExpressions.Regex.Matches(s,"(?<=^|\n)\d+\s[\s\S]*?Sub Total.*")

Regards,

1 Like

both work for me . thank you :grin:

1 Like

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