Regex help lookbehind

Hi,

I need to get the two first numbers from the total line in below PDF string and I have difficulties with the lookbehind. The numbers can vary in size.

Here’s what I have: (?<=TOTAL:\s{2})(\d+,\d{3}.\d{3})|\d+.\d{3}|\d(?=_)

but I get all matches from the table as well. I need to only get matches from the total line.

HU ID GROSS NET DIMENSIONS VOLUME
HU TYPE WEIGHT (KG) WEIGHT (KG) LxWxH (M) CUBE (M3)
LRC3496749 2.200 2.008 0.260X0.210X0.430 0.023
Dealer & Transp
LRC3496764 4.500 4.425 0.260X0.210X0.170 0.009
Dealer & Transp
LRC3520091 175.000 136.847 2.200X1.250X0.880 2.420
Dealer & Transp
LRC3523235 107.000 68.468 2.200X1.250X1.100 3.025
Dealer & Transp
LRC3523236 215.000 176.929 2.200X1.250X0.940 2.585
Dealer & Transp
LRC3523237 65.000 26.977 2.200X1.250X0.700 1.925
Dealer & Transp
LRC3527618 54.000 48.950 2.200X1.370X1.740 5.244
Dealer & Transp
LRC3527636 21.000 16.000 2.010X0.840X0.900 1.520
Dealer & Transp
LRC3527809 67.000 61.840 2.200X1.320X2.170 6.302
Dealer & Transp
LRC3586675 95.000 76.113 1.100X1.100X0.720 0.871
Dealer & Transp
LRC3586690 81.000 68.718 1.060X0.740X0.690 0.541
Dealer & Transp
LRE1140377 160.000 150.000 0.940X0.930X0.990 0.865
Dealer & Transp
LRG1093858 142.000 75.320 1.900X0.660X1.440 1.806
Dealer & Transp
LRG1093992 8.000 5.115 1.060X0.740X0.100 0.078
Dealer & Transp


TOTAL: 1,196.700 917.710 27.214


Someone who can help? :slight_smile:

Thanks a lot!

Hi @stch

Try this regex pattern

Regards

Nived N

Happy Automation

Thanks, that’s a start. Is there any way to capture the numbers in different matches?

Hi @stch

After extracting the number using the above regex and storing the output in string format let’s say input

Spilt string according to whitespaces

list_1= Split(input," ")
Where list_1 is array of string

list(0) retrive the first number and list_1(1) retrive the second number

Hope it helps you

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

Hi @stch

Try

TOTAL:(\s*([0-9]{1,3}(,[0-9]{3})*(.[0-9]+)?|.[0-9]+)){1}

for first number and

TOTAL:(\s*([0-9]{1,3}(,[0-9]{3})*(.[0-9]+)?|.[0-9]+)){2}

for second number

Best regards,
Liviu

Thanks both for your help!

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