Regexx help please


I would need some help on a regex script. I need to be able to take the following out from this text
“Fred”, “Bloggs” from this text

"uipathbottesting-31113d164599161@mail-eur.niceincontact.comSubject: Track_00000001\n\n\n \n \nContent-Type: text/plain; charset=us-ascii\nContent-Transfer-Encoding: 7bit\nDate sent: 23/02/2016\nTime sent: 9:14:28\nTitle : Ms\nFirst name: Fred\nLast name: Bloggs\nDate of birth: 30-Oct-1966\nAddress line 1 : 35 The High Street \nAddress line 2 : Bristol \nAddress line 3 : \nAddress line 4 : \nPostcode : BS2 8YQ\nEmail Address:\n\nApplication number : 3265331111\nDate application submitted :\nComments :\n \n \n\nGeneral\n\n\n\n\n\n"

Any help would be appreciated!

To obtain the name, you can use the following Regex:

(?<=First name: )\w*


and for Last Name:

(?<=Last name: )\w*


How it would look like in UiPath:

Welcome to the forum

have a look here:

strFirstName =  System.Text.RegularExpressions.Regex.Match(strText, "(?<=First name:).*").value.Trim
strLastName = System.Text.RegularExpressions.Regex.Match(strText, "(?<=Last name:).*").value.Trim

we assume that the \n are coming visual from some panel output copy / pastes. When \n as string value and not as Line break is within the text we can do:

If first and last name always contains one word without apostrophe or hyphen then @ignasi.peiris solution should work. Otherwise try:

System.Text.RegularExpressions.Regex.Matches(YourTextSample,"First name: (.*?)\\nLast name: (.*?)\\n")(0).Groups(1).ToString

for first name, and:

System.Text.RegularExpressions.Regex.Matches(YourTextSample,"First name: (.*?)\\nLast name: (.*?)\\n")(0).Groups(2).ToString

for last name.

Hi @josefine.thoren1

Welcome to community

Try this expression

System.Text.RegularExpressions.Regex.Match(YourTextSample,“(?<=First name: )\S+(?=\)”)

System.Text.RegularExpressions.Regex.Match(YourTextSample,“(?<=Last name: )\S+(?=\)”)



Thanks for your answer. It works when I do it in the Regex tester but when I run the bot I can see it successfully takes out the first name “Fred” but not Last name “Bloggs”. I don’t know if it it because the data is retrieved in a new row when running the bot? Any ideas?


thanks for the feedback

maybe you can:

  • reupload the image:

as multiple suggestions were shared with you, let us know which detailed one was used
also give some more hints on the input. When it is variable then share with us the output from immediate panel
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

sound like looping over a datatable… maybe you can share some screenshots from your modellings as well


Hi @josefine.thoren1

Have you tried my expression?


Thank you! I managed to get it working for everything but the last one. It works in the regex builder but then when I run it I can see the IEnumerable variable is empty.