Regex value at columns in PDF file

Hi Everyone.

I have used this regex code to extract value at columns in PDF file.

Code: Regex.Replace(Regex.Replace(Regex.Match(pdfText, “(?<=(Total\ charges):?)\ .*”).ToString.Trim, “\ {18}”, " 0 ").ToString, “\ {2,}”, " “).ToString.Split(” "c)

I want to return “0” if the value at column is blank… But it not return correct result as in the attached picture.

Is there any not correct and how to fix in my regex code?

Thanks in advance!

if that regex ia working fine then if that part is not there it’ll return blank sl you can use a if condition to check if the output is blank then assign zero accordingly.

1 Like

Hi Bro.

The first column is blank, but it not return “0” at the 1st position.

The correct result must be: 0,720.000,0,72.000,0,790.000

Hi,

Can you try the following expression? Perhaps you should use TrimEnd instead of Trim.

Regex.Replace(Regex.Replace(Regex.Match(pdfText, "(?<=(Total\ charges):?)\ .*").ToString.TrimEnd, "\ {18}", " 0 ").ToString, "\ {2,}", " ").ToString.Split(" "c)

Regards,

1 Like

Hi Bro.

I have tried and the result return empty all.

Hi,

Can you share content of pdfText variable or result of Regex.Match(pdfText, "(?<=(Total\ charges):?)\ .*").ToString as a file?

Regards,

1 Like