Matched Regex Returns Empty

Hi all, I would like to seek some help and advise on the following:

I have a matched regex expression when I test it with the Regex Builder. Basically, I want to get the Total Amount “750.00” after “EXW USA”. My regex expression is meant to capture the decimal amount after “EXW [country]” or “FOB [country]”.

But I am going round in circles figuring out why it is returning empty value with my assign statement. I would appreciate any advice and guidance.Main Regextest.xaml (7.3 KB)

Use this regular expression, but trim the result when you’ve fetched it: (?<=EXW\sUSA)\s*\d+(\.\d+)*.

1 Like

Hi, thank you for the suggestion. Maybe I did not mention clearly. Even though my input string is fixed, but in my actual application, the “country” is a variable, not fixed to “EXW USA” as in the tring. So if I use this regular expression`(?<=EXW\sUSA)\s*\d+(.\d+). then I would have to add to the list to cover all other countries such as (?<=EXW\sUSA)\s\d+(.\d+).| (?<=EXW\sJAPAN)\s\d+(.\d+)*…


I don’t have UiPath on this computer so I didn’t check your file. Maybe this will help. If you need to add other incoterms, you can tweak related pattern’s group accordingly.

Assign (String)
pattern = "(?<incoterms>EXW|FOB)\s+(?<country>\S+)\s+(?<amount>[\d\.]+)"

Assign (Match)
match = System.Text.RegularExpressions.Regex.Match(myText, pattern)

Assign (Decimal)
amount = Decimal.Parse(match.Groups("amount").Value)

Hi msan,
Thank you. It works as I needed after some modifications. As a beginner to regular expressions, making use of pattern groups is new to me. Cheers.

1 Like

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