Hope you all doing well.
I have a doubt and I would like you to help me.
I’m trying to extract two adresses from an email. The Inbox receives the e-mail in a standard model, just like that:
Address 1: Rua Jose Augusto Rodrigues 174
City:sao paulo - sp
zip code: 99837464
Retrieve time:08:00 to 08:00 pm
The two addresses are just like the above standard on the e-mail body.
I’m already using the get mail outlook message activity to read the body.
Specifically, I need to record in the variables, the string from “Address 1” until “John” in str_adr1 and the second address in str_adr2.
Anyone has any idea of how can I do it?
Thanks in advance,
You can use the regular expression for this, there is search option to check the start and end of matching result so try regEx.
Thanks for the help.
I’m new at uiPath programming and still not understand how works the syntax of regex.
Could you please show me how it works?
Thanks in advance.
Is the john word is fixed?
if so try the below regex, it works.
Test it here:
regex101: build, test, and debug regex
Thanks for your help.
But if you could, I still need your help.
I’m already saving the e-mail body into a variable.
After using the regEx formula, I need to save the result into another variable and paste it into a field in the ERP.
Below, is the information that I need to record into the address variable.
Do you have any idea of how can I do it inside the uiPath using the Assign activity?
Thanks in advance Meg,
The syntax for the Assign activity would look like that:
yourNewVariable = System.Text.RegularExpressions.Regex.Match(yourOldVariable,"Retrieval address:([a-zA-Z\s\S]*?)^\s*\n").ToString
This will Assign the result of the Regex search to a new variable.
Thanks for your help!
I used your syntax adapted to my project, but it still not worked, I used a message box to show the result of the Regex based on the body of the e-mail and it returns a blank message as if mail body was empty…
Do you have any idea of the reason that it occurs?
If necessary, I can share my project for easy analysis.
Thanks in advance.
I updated the Regex a bit, hopefully it still fits your needs (same output, different boundary condition):
System.Text.RegularExpressions.Regex.Match(inputString,"(?<=Retrieval address: ).+?(?=Pick up address:)",RegexOptions.Singleline).Tostring
Refer to the attached workflow for to see it in action
RegexSearch.zip (2.3 KB)
Thank you very much for your help!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.