Unable to split a string

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:

Try this and let me know

Regards,
NaNi

1 Like

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.Match(outputPDF,"\d[,\d]*").Value

Regards,

1 Like

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

I needed the link badly, to study more about this issues… Thanks!

1 Like

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

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]

This is not working :frowning:

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:

Regards,
NaNi

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

Thanks a lot @THIRU_NANI and @Yoichi :saluting_face:

1 Like

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