I am looking for some assistance with Regex in splitting the Name field in an email and outputting the results into two variables. Example of the email is below.
Email Template example:
“name : Jo-anne Smith
email : Jo-anne.Smith@gmail.com
Phone : 0400 123 456
additional-comments : Hi
I need to request a leave form.
Kind regards,
Jo-anne Smith”
I would like to be able to grab the first name ‘Jo-anne’ as the first name variable and ‘Smith’ as the surname variable.
I think I have the first name figured it out (some feedback would be great) but I am unable to figure out the surname field.
Regex for first name:
(?<=name : ).*(?= )
Any assistance would be greatly appreciated.
I found this video somewhat helpful but I still couldn’t apply it to my scenario 2 Lookaheads - YouTube
I tried your regex suggestion:
(?<=name : )(.+)(?= (.*))
It’s a very good match for my needs but I am having no luck applying it in UiPath. Through my attempts to implement (and limited knowledge) I can only get either a single character returned (J) or the entire name (Jo-anne Smith) in the outputs pane.
I think I am having trouble correctly referencing the Group 1 (Jo-anne) and Group 2(Smith) from the regex match.
Your suggestions work! but the First name solution needed to be modified. (I removed the second "name: ". This was overriding the First name text. I have used it successfully for the First name and Surname. Below is my modified First name value in my Assign activity.
First Name:
VarFirstNameString.Substring(VarFirstNameString.Indexof(“name:”)+" “.Length).Split(” ".ToCharArray)(0)
Your solution was the only one to work for me first time
Your regex and instructions appeared to work (from what I can tell) because of the matches and groups combination. Unfortunately I need the 'name : ’ anchor in the regex to ensure I collect the right names each time (in production these emails are often forwarded from another person - I know I didn’t mention that in my post ).
Thank you for your assistance, I learnt something from your regex (I am new to regex FYI).
Thanks for your really quick response to my posted workflow
Unfortunately your amended workflow did not work for me. The surname was blank and first name had the full name. Please let me know if I am missing something.
name : Jo-anne Smith
email : Jo-AnneSmith@gmail.com
phone : 0400 123 456
organisation :
additional-comments : Hi
I need a leave form sent to my email address
Thanks
Jo