Mr.H
October 12, 2021, 3:24am
1
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
Mr.H
October 12, 2021, 3:29am
3
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
Yoichi
(Yoichi)
October 12, 2021, 3:59am
4
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
Mr.H
October 12, 2021, 7:08am
5
Yoichi:
Regex.Replace(Regex.Replace(Regex.Match(pdfText, "(?<=(Total\ charges):?)\ .*").ToString.TrimEnd, "\ {18}", " 0 ").ToString, "\ {2,}", " ").ToString.Split(" "c)
Hi Bro.
I have tried and the result return empty all.
Yoichi
(Yoichi)
October 12, 2021, 8:04am
6
Hi,
Can you share content of pdfText
variable or result of Regex.Match(pdfText, "(?<=(Total\ charges):?)\ .*").ToString
as a file?
Regards,
1 Like