Zeba
(Affy)
July 18, 2022, 11:59pm
1
Hey All,
This is very simple but I am unable to achieve it. Definitely a silly mistake that I am doing, can anyone please have a look and suggest me the solution, I have been trying this from few days.
I have a pdf from which I am trying to extract a specific text which is the amount.
In the assign activity
Total = split(outputPDF,environment.NewLine)(41)
I am getting the output as shown in the picture, expecting to be only digits “650,00”
I tried
UiPath Forum 1
UiPath Forum 2
Thanks, and Happy Automation!
Hey!
We can do like this
Create a string variable in variable panel-Total
Take one Assign activity
Total = System.Text.RegularExpressions.Regex.match(PdfOutput variable,"(?<=TOTAL\s)\d.*").ToString
This will give you the total
Reference:
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.
Try this and let me know
Regards,
NaNi
1 Like
Yoichi
(Yoichi)
July 19, 2022, 12:10am
3
Hi,
Can you try the following expression?
System.Text.RegularExpressions.Regex.Match(outputPDF,"\d[,\d]*").Value
Regards,
1 Like
Zeba
(Affy)
July 19, 2022, 12:25am
4
Thanks, @Yoichi & @THIRU_NANI
This works, for the above example. But I am getting another issue now, which I should have added in the question.
I have N number of PDF’s and some have the amount as
1 100,00
2 150,05
650,00
950,00
Both the solutions are working but the results are different
1 100,00 Prints → 1
2 150,05 Prints → 2
650,00 Prints → 650,00 [Correct Output]
950,00 Prints → 950,00 [Correct Output]
Hey!
Could you please paste the pdf text here?
Regards,
NaNi
Zeba
(Affy)
July 19, 2022, 12:27am
6
I needed the link badly, to study more about this issues… Thanks!
1 Like
Yoichi
(Yoichi)
July 19, 2022, 12:27am
7
Hi,
How about the following?
System.Text.RegularExpressions.Regex.Match(outputPDF,"\d+,\d{2}").Value
Regards,
Hey!
You can learn more about regex here…
Regards,
NaNi
2 Likes
Zeba
(Affy)
July 19, 2022, 12:31am
9
INVOICE
1 Main Road
Johannesburg
South Africa INVOICE # DATE
leon@robopro.co 5536 2018/08/17
CUSTOMER ID TERMS
97 Net 30 Days
BILL TO
Denny Barkaway
Jamia
8 Prentice Road
Xihanling
354-626-9437
dbarkawayl7@state.tx.us
DESCRIPTION QTY (hours) UNIT PRICE ($) AMOUNT ($)
Service Fee 2 200,00 400,00
Additional Services 7 75,00 525,00
Thank you for your business! TOTAL 1 925,00
If you have any questions about this invoice, please contact
[Leon, leon@robopro.co ]
Zeba
(Affy)
July 19, 2022, 12:36am
10
This is not working
1 100,00 Prints → 100,00
2 150,05 Prints → 150,05
Expected
1 100,00 or 1100,00
2 2150,05 or 1100,00
Hey!
Try this:
System.Text.RegularExpressions.Regex.Match(inputVar,"(?<=TOTAL )\d.*").ToString
Reference:
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.
Regards,
NaNi
Yoichi
(Yoichi)
July 19, 2022, 12:39am
12
Hi,
Alright, the following will work.
System.Text.RegularExpressions.Regex.Match(outputPDF,"\d[ \d,]*\d").Value.Replace(" ","")
OR
System.Text.RegularExpressions.Regex.Match(outputPDF,"(?<=TOTAL\s*)\d[ \d,]*\d").Value.Replace(" ","")
Regards,
1 Like
Zeba
(Affy)
July 19, 2022, 12:42am
13
Thanks a lot @THIRU_NANI and @Yoichi
1 Like
system
(system)
Closed
July 22, 2022, 12:42am
14
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.