Regex Text extraction issue

Hello

I have a RegEx issue which I hope you can help with.

Below is an extract of Text which appears in a much larger document


Quantity U.O.M. Supplier Description Delivery Unit Price Line Value
Required Part Number Date Including Discount GBP

1 EACH Acrobat Pro Version 2020 AOO License 1 User/ 474.29 474.29

Instructions to Supplier: This order is subject to the standard Terms and Conditions of contract. For a copy of these please contact the Buyer for this order. Any price alterations must be agreed
with the buyer prior to order execution. The above order number must be quoted on all invoices, acknowledgements, delivery notes and other correspondence. A delivery note must accompany each
consignment of goods. The order must not be passed to any third party for supply. Any invoices not complying with these instructions will be returned unpaid to the supplier.


The output I want to obtain is the second 474.29

I have tried this in regex101.com and the code works - please see screenshot

The required pattern to be extracted is the last set of figures on this line
1 EACH Acrobat Pro Version 2020 AOO License 1 User/ 474.29 474.29
or it may be
3 EACH Acrobat Pro Version 2020 AOO License 1 User/ 474.29 1422.87

The figure 1422.87 (variable) may appear with or without a comma - it may be 1,422.87

As far as the single value goes, the code
\bAcrobat.+? (\d+.\d+)$
works in Regex101.com and returns the final 474.29 BUT does not work in Studio

Can you assist please

can you try?
\bAcrobat.+? ([\d,.]+)$

@ppr
No, sorry that has not worked either

we do see this

when in Studio you get a different result then:

  • show us what was done
  • prototype it within immediate panel and share with us the details and outputs

Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Hi @gary.cobden

Try this syntax:
System.Text.RegularExpressions.Regex.Matches(input,"(?<=\s).?\d+\.\d+(?=\n)")4
Datatype: IEnumerable(System.Text.RegularExpressions.Match)



image

Regards,

@gary.cobden

Use Find Matches activity
or

System.Text.RegularExpressions.Regex.Matches(“InputData”,“Expression in Screenshot”)

Morning
@ppr
@rigandu
@Parvathy

Still cannot seem to get this to work
Attached is my xaml and sample pdf file
wonder if that helps

test.pdf (53.1 KB)
Test.xaml (8.4 KB)

Your assistance is appreciated. I have got other regex expressions to work (stripped out of this file) but this one is proving difficult

Thx

Just do some experiments within the immediate panel and play with the line ends \r \n $
Starter Check V2:
grafik

When working with the Matches Activity also have a focus on the regex.options:
grafik

So, it is recommended to have it in sync between experiments e.g. done with regex101 for the relevant parameters

@ppr

I am getting the error
BC30456: ‘groups’ is not a member of ‘MatchCollection’

Yes, it is a member from the match. So loop or grab a particular match

[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

As mentioned, use the dedicated Element from the matchcollection

Sys…Matches(…).elementat(0).gr …

Or use Regex.Match

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