Hi guys!
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
District:Moema
City:sao paulo - sp
zip code: 99837464
Retrieve time:08:00 to 08:00 pm
A/C:John
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,
Renan Maciel
megharajky
(Megharaj Yadravi)
November 23, 2018, 8:07pm
2
Hello,
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,
Meg
Hi Megharaj,
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.
Renan Maciel
megharajky
(Megharaj Yadravi)
November 27, 2018, 7:03am
4
Hello,
Is the john word is fixed?
if so try the below regex, it works.
^Address([a-zA-Z\s\S]*?)John$
Test it here: regex101: build, test, and debug regex
Thanks,
Meg
Hello Meg,
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.
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.
Do you have any idea of how can I do it inside the uiPath using the Assign activity?
Thanks in advance Meg,
Renan Maciel
loginerror
(Maciej Kuźmicz)
December 7, 2018, 9:04am
6
Hi @renanmaciel
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.
Hi @loginerror
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.
loginerror
(Maciej Kuźmicz)
December 8, 2018, 2:15pm
8
I updated the Regex a bit, hopefully it still fits your needs (same output, different boundary condition):
https://regex101.com/r/Ynk4Wc/1
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)
4 Likes
Hello @loginerror !
It worked.
Thank you very much for your help!
system
(system)
Closed
December 13, 2018, 7:35pm
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.