Regex help tutorial MEGAPOST – Making your first Regex post, Reusable Regex Patterns, Regex Troubleshooting, Sample Workflow and more


If you need help with Regex be sure to provide in your post, a Sample, the Output and the Pattern (as much as you know).

Section :one: : I need a Regex Pattern ASAP! :fast_forward: - My first Regex Post :boy:
Section :two: : Regex samples that you can use! :nerd_face:
Section :three: : I need help applying regex in UiPath :raised_hand:
Section :four: : Regex Matches and Groups :people_holding_hands:
Section :five: : Learn Regex in 60 mins :green_book:
Section :six: : HELP Regex isn’t working in UiPath!!! :scream: – Regex Troubleshooting

CLICK HERE to Download this UiPath Studio REGEX DEMO (13.0 KB)
Watch this UiPath Regex Tutorial in less than 2 mins:
Regex + 1 Assign activity = Result (in String)

SECTION :one: : I need a Regex Pattern ASAP! :fast_forward: - My first Regex Post :boy:

If you truly need help please provide the following AS A MINIMUM.

  1. SAMPLE - Provide a sample (or 3) of your raw text in your post (or upload a notepad file or PDF )
  2. OUTPUT - Provide the output after the raw text (bolding of the output helps also – optional )
  3. PATTERN - What is always consistent? Tell us as much as possible about the pattern of the text (example: It will ALWAYS be 2 capital letters, a space, then 4-6 numbers)


  • Provide as much information as possible. Every little bit helps and you will get a stronger Regex Pattern in less posts.
  • Will it change? (Capital letters, combination/amount of words/numbers, how many spaces does it have, is it consistent?)
  • Is there multiple matches or just one in your text?
  • Are you using OCR?
  • Can you use Regex in UiPath?

Regex relies heavily on finding a pattern that is constant and specific enough to match all occurrences but without false positives.

Spend 5-10 minutes making a quality post and I GUARANTEE :crossed_fingers: it will save you time in replies and you will have an answer MUCH faster from a UiPath Forums Hero :superhero: :woman_superhero: - they might even give you back an actual working UiPath solution :open_mouth: (it’s a great community :white_check_mark: full of Champions :nerd_face: so save everyone some time :clock1030: and submit a quality post)

Here is an example forum post:

" Hi All

I need a regex pattern to grab the state and postcodes from the below text.

  • Sample text provided below
  • The expected output I am seeking is below:
    • RI 55924
    • VA 34075
    • AK 86847
  • The pattern of the text: The State will always be two capital letters, a single space and the ZIP code will always be 5 numbers following that.* (AB 12345)

Any help would be appreciated. :slight_smile:

Thank you.

Sample text:

Dave Martin
173 Main St., Springfield RI 55924

Charles Harris
969 High St., Atlantis VA 34075

Eric Williams
806 1st St., Faketown AK 86847"

End of post…

You will have a response from the UiPath community with an answer in no time! [A-Z]{2}\s[\d]{5}

Remember, Sample, Output and Pattern. SOP.

Check out this great post about asking the right question in the UiPath Community Forum :slight_smile:

SECTION :two: : Regex samples that you can use! :nerd_face:
(I STRONGLY recommend watching this video first - Learning and Understanding Regex)

Click the hyperlinks below for the full sample text.

*This is not an exhaustive Regex list. If you are unsure if you have a robust pattern, make a post to verify.

When to use: When you have a fixed word that wont change and need to match the string after or before.

Anchor Samples below (will grab the word John Smith):
Words in the brackets can be replaced but MUST be exact (or literal).

Name Example 1:
Payee: John Smith

Regex pattern: (?<=Payee: ).*
Comments: Fine to use if it’s the only string on the current line.

Name Example 2:
John Smith – Payee

Regex pattern: .*(?= - Payee)
Comments: Fine to use if it’s the only string on the current line.

Name Example 3:
Payee - John Smith - Account

Regex pattern: (?<=Payee\s-\s).*(?=\s-\sAccount)
Comments: This will capture everything between the words “Payee – " and " – Account”. This solution should be fine to use as long the words Payee and Account are constant.

Account Numbers Example
145 567 981

Regex pattern: \d{3}.\d{3}.\d{3,4}
Comments: The above pattern will match 3 digits followed by anything followed by 3 digits followed by anything followed by 3 or 4 digits.

Date Examples

Regex Pattern: \d{1,2}.\d{1,2}.20\d{2}
Comments: This pattern will work for the next 100 years and will match all three examples above (because of the “.”)

Time Examples

Regex Pattern: \d{1,2}:\d{1,2}
Comments: 1 or 2 digits separated by a “:” followed by 1 or 2 digits.

Email Examples
Email Regex can be very challenging and can change depending on domains.
Below is a sample solution but test, test, test to ensure its fit for purpose.


Regex pattern: ([a-zA-Z0-9_-.]+)@([a-zA-Z0-9_-.]+)\b
Comments: Ensure you have tested that it will work with your email domains and so on.

SECTION :three: : I need help applying regex in UiPath :raised_hand:

Watch this 10 min video from @AndersJensen (Best YouTube Channel for UiPath in my opinion)

This is the process:

  1. You will need to first get your raw text into UiPath.
  2. Then you will need to use a ”Matches" activity.
  3. The Pattern will be the Regex Pattern/solution from the forum post.
  4. Input will be your Raw Text variable
  5. Result will be the output which is a variable type called an “IEnumerable” .


What is an IEnumerable?” you say, well:

  • An IEnumarable is a collection of results (like an array).
  • Even if you only have one result it will still be treated as a collection.
  • To get the result, you will need to type a digit in brackets after to reference the result and group. 0 = is the first result only, 1 = the second result:
    • VARIABLE(0).Tostring
    • VARIABLE(0).Value

Download this UiPath Regex Demo I made so you can see what to do.xaml (13.0 KB)

SECTION :four: : Regex Matches and Groups :people_holding_hands:
When using Regex you will always have a full match but sometimes your Regex pattern might be made up of 1 or more groups. The number of groups can be 0. Having groups may also be an intentional design (to make the pattern robust) so you can grab elements later – like the year or month separately.

Take a look at this solution for an example

To get Group 1:

To get Match 2:

To get Match 3:

Then use an assign activity and update the capital letters with the variable from the Result field in the Matches Activity.

Download this UiPath Regex Demo I made so you can see what to do.xaml (13.0 KB)

SECTION :five: : Learn Regex in 60 mins :green_book: (and understand Regex for next time :stuck_out_tongue_winking_eye: )

To learn Regex there are a number of tutorials on YouTube but I STRONGLY recommend these videos:

To Understand and Learn Regex watch this video - 38mins:
Regular Expressions (Regex) Tutorial: How to Match Any Pattern of Text. I personally watched this video and started here. Tip : take screenshots and save them in MS Word :brain:

How to apply those learnings in UiPath watch this video - 11mins:
UiPath | Matches and Regex | Simple and Complete Tutorial. This tutorial is simple and concise. One of MANY amazing tutorials by the great @AndersJensen!

To Practice Regex, use the samples from the 1st video’s description and head over to the following sites:

Please note - the MOST compatible site with UiPath is .NET Regex Tester - Regex Storm NOT There are differences between and UiPath. is more popular because of the following features:

  • share\save your patterns with users on the forums. Using the “Save Regex” function (ctrl + s) in the top left of the window – like this custom save.
  • understand your regex pattern/result from the Explanation section (Red :red_circle: circled section to understand).
  • improve your pattern using the Quick Reference section (Green :green_circle: circled section) – its a great tool and I still use it regularly to refresh/brush-up.

SECTION :six: : HELP Regex isn’t working in UiPath!!! :scream: – Regex Troubleshooting
On occasion reading a PDF (or other documents) and storing it as a string will cause an error with UiPath.

UiPath will give you error messages like:

  • “Object reference not set to an instance of an object”, Or
  • “Illegal characters found in path”.’



1st step is to always triple check your Properties (Regex input, Regex Pattern and the Output).

Some Possible cause/s:

  • Possible Cause 1: One possibility is you didn’t get a match and you need to check your sample data. Is the text mandatory? Is your Regex Pattern robust? Are you using OCR?

The solution: You need to check the count of the results to a message box. To do this insert the following into a message box:
(Replace capitals with your actual Result/Output variable in the Matches Activity). Also use an IF condition to error handle your workflow (see image).

Like user:ClaytonM has suggested here in this post.

  • Possible Cause 2: Another reason is on occasion UiPath thinks there are invisible characters (whether there is or not) and can’t find a match or process because of the illegal/special characters. This can happen with a folder path also. (Please don’t ask why because I don’t know :laughing:)

The Solution: – Is simple, you must trick UiPath by “CLEANING” your variable using the replace method (Use a Replace Activity to filter/remove unwanted characters).

Check out this UiPath Regex Demo with a CLEAN STRING example.xaml (13.0 KB)

DirtyVariable= Dave Martin
173 Main St., Springfield RI 55924

CleanVariable = System.Text.RegularExpressions.Regex.Replace(DirtyVariable, “[^a-z A-Z 0-9]”, “”)
This will replace all characters except these: (^a-z A-Z 0-9) with nothing (""). Update the brackets in the above as necessary.

CleanVariable = Dave Martin6155557164173 Main St Springfield RI 55924davemartinbogusemailcom

This text will now be 100% suitable for Regex. If you wanted to keep the spaces just add a “\s” to the “[ ]” brackets.

Some developers will clean all strings before using them.

SECRET :male_detective: BONUS SECTION: Celebrate you Regex Champion! :love_you_gesture: :man_student: :champagne:
Thanks for reading this far :blush:

Please bookmark this post, show it some support by clicking the :heart: and share it with new users.

Other MEGAPOSTs worth looking at:
Please take a look at these other valuable fantastic MegaPosts:

  • Regex Cheatsheet by (@)ppr for more “System.Text.RegularExpressions” Regex methods and options :blush:
  • String Manipulation by (@)Adrian_Star for everything on String manipulation.
  • DateTime MegaPost by (@)Palaniyappan. This is very handy post for all things Date Time related.

Feel free to message me :email: if you have a Regex problem but make sure you provide SOP as per Section :one: (Sample, Output, Pattern).
Also, Rookie UiPath Developers you REALLY need to subscribe to @AndersJensen on YouTube (here is a link to his channel) and check out his dedicated playlist for Rookies (UiPath Tutorial: The Basics for beginners). Anders has the best UiPath content on YouTube in my opinion (that’s a whole other post though).

Remember there are PLENTY of Regex legends :brain: on the forums! (I am simply a Regex Lover and aspiring to help as many people as I can)

The forum chamions I see on the forums are: supermanPunch @Palaniyappan, Pratik_Wavhal, @ppr, msan, @Yoichi, bcorrea, Pradeep_Shiv, Pablito, lakshman, Arpit_Kesharwani, Anthony_Humphries and mzahid).
I can only tag 4 users in this post but just put a ‘@’ in front of the usernames… All are amazing :brain: in my book :smiley:

Hopefully you found this post helpful and the standard of Regex posts improves in the forums :blush:

Happy Automation!


[CheatSheet] - System.Text.RegularExpressions | RegEx
Extract specific data from txt file to dt
Keep value inside ()
#FeatureBlog - 19.10 - Using regular expression (Regex) in the selector attributes
Regex: Many lines with same word, grab until line with 1st occurrence
BLOG: My name is Anders and I’m allergic to manual work
How to extract year only from a string and assign it to a variable
Extract the next line after specific phrase
String Manupilation
Regex Issue (Any)
Modify text -> Find and replace text
Regex Expression with different format of string
Hi I’m new to UiPath here Need help with extracting Email subject
Need help with idea for string manipulation
Regex to test if strings exist in a string to match
Extract dynamic text from string
Regular expression to select alphanumeric characters and only first occurance of $ in string "foo$blahblah$123$$"
How to split large string to get specific element
My regex isn't working but works in regex builder and regex101
How can i extract many information from pdf from page 16 for example plz
Regex from String
Extract the last version name of a folder as a text string
How to use text to column?
One variable and cut into several variables by comma
RegEx help - Invoice Extraction
Use regEx to find text
Extract part of specific text line
How to read specific patterns of string (by following an order) - Telegram
Get the numbers in a string
How to put Regex capturing groups into uipath
How to check if a string has a certain pattern?
Extract line from pdf with regex
How to extract Access Code from email
Get the text after a certain word
Indexof Position Notepad
Regex operator question
How to dynamically extract string using regex?
How to dynamically extract string using regex?
How to extract the string values
Ressources for UI Path - Twitter accounts, blogs etc
Get Outlook Mail Message-How can I copy body and paste with values?
Split from the beginning of any letter
Extract date from a sentence
Regex not woring
How to find a fixed starting position in PDF when the format is not fixed
Split Address String without break in words
How to execute a list of commands in cmd
Regex to find the 2nd occurance
Matches activity throws object reference error when using a regex pattern
Extract line from pdf with regex
dd-dd/MM/yyyy date type problem
How to remove specific texts from Get Text
Get 3 different values with regex?
How to spilt a variable with double spacing?
Regex for URL
Extract only characters from string
Regex capture a word blow a specific word / regex next line
Need To Extract Auth Token from Email and then Enter it into Application
Txt file to Excel file
Regex to remove ID tags
Text to Left/Right, is it possible to use a new line as separator?
Parsing texts to get names, claim numbers, date etc
I need to extract the value using regex
I need to identify the value of text in text document but that text occur multiple time
How to spit string in notepad
How to use Split or use Regex if I want to Split a list of text by "."
Extract text with regex
Text Extraction : String Manipulation/Regex
Additional RegEx Help
Extract date like strings from long string
RegEx to extract all data between two patterns
Regex Date
How to split multiple row t single row using Regex
Extract currency value using regular expressions
Please guide me about read text file
Regex Value
How to extract particular data from a multiple pdf that have multiple pages using anchor base,find element,get text?
Regex replacing
RegEx pattern ********** not contain any character or number
How to split the String variable
Regex Expression to find city and zip from address
How get specific word from email body
Регулярные выражения
Regex Expression to find city and zip from address
Advanced text file data extraction
Regex Expression to find city and zip from address
How can i remove all the links and extra spaces from a email body
How to read PDF using Regex?
Regex without duplicate in UiPath
ERROR : Source: Assign "Message: Object reference not set to an instance of an object."
Find the text adjacent to a string and extract the value
How to split address and extract the postal number from address?
Getting Data from Text file
Check if the column has empty or miscellaneous data
:Santa: Advent Challenge #2 (Everyone welcome to join the event!)
How to replace wildcards with regular expressions
Regex - extract sum from text
Extract Product Name and Price from PDF without using OCR
Unable to split string using matches
Read PDF text for new Invoice template PDF
How to extract multiple data from PDF
How to extract multiple data from PDF
Get part of a text from a string
Unable to extract these values from PDF
Regex for specific pattern containing multiline text
PDF Extract Text
Regix help
Identifying and extracting date from Word Doc
How do use RegEx Matches and Replace
Find upper letter regex
Get values after specific text
Get Emp_name and Emp_id from array string
I need to scrap data from a text file which looks like junk[but it is actually data extracted from OCR ID card].Now I want to transform it to structured Excel file with the Name,ID card number,Nationality etc..Plz help me in this
How to identify specific string in a mail body with Regular expressions?
How to extract specific part from a string using specific separator and add those string in an array/collection and loop through it
How to build or what are the basics in building regular expressions?
How to build or what are the basics in building regular expressions?
Filter out a link from a message
Email Body Manipulation
RegEx for pdf US date
Regex to extract data between dates
Need Help on REGEX Project
Not able to retrieve Invoice details using Regex only
Get a single value from a sentence
Trying to get data but they end with the same word (except one has more words in front of it) (Makes more sense in the post)
Add separator using the regex
How to split address
How to split address
How can I extract an embedded PDF from an XML file?
To extract string from a text file
For each collections Matches
How to and where to learn Vb.Net Expressions/functions
What does aaname *:? do
Check file in path with specific format name
How to save only specific keyword from DB
How to filter attachments for example images in the body of the email?
Regex grouping
How to extract all the numbers(1018751952 1018741953 1018867777 ) of length 10 starting with 1018 in mail body of outlook?
Regex to extract the last amount including the negative
Add a space before the first digit in a string
Using Regex
Extract numbers only from Excel column
Extract specific text from the html body string (from the HTTP request)
Remove character in string that is between curly braces
How to split unstructured data
How to get a whole string between two words?
Help with regex pattern
How to remove specific dynamic string
How to get line before and after specific line in text file
.Net Technologies to learn
Need help to learn Regex
How to get integer from string?
How to manipulate an object extracted by Regex and Match
Regex and replace
How to read the specific data in pdf
Split spacific text from e mail body
Keep string after a certain word
Extracting PDF Unstructured Data with irregular format
How can i extract 8904231549845 this value from entire item description column and create a new col and insert the value into it?
How to get the particular value from excel
PDF data formatting
Text file automation
Need help with regex, to search consistant for string value
Copy the body of an Outlook Email and put into an Excel sheet
Remove blank row when read text file
Extract table from PDF file
Regex- find string
Any regex for alphanumeric extraction in matches activity of uipath? for e.g. to extract this?
Help with linking Excel cell value with Regex pattern
Regex match pattern up to but exclude optional
How to extract a specific word from a string using REGEX in uipath?
Regex difficult to create
Any help on a regex?
Regex Extraction Text
Read file by regex?
Find specifig word and catch following then send to excel in batch
How to extract date from Email body
Unable to open file using start process activity
Working Multiple PDF's With OCR
How can i find the matching values in my string?
String Problem
Text extraction from string
How To Get All Words from a Text File using RegEX?
Is it Possible to Delete Rows ( Words) Which Contains Successive Consonants or Vowels?
How to add "-" between alfa and numeric
How to split text and Number in Excel Cell
Regex to check if subject format was followed
I need regular expression for below following text
Need practice test to better understanding of regex
Variable consists of 15 digits number, I want to read first 4 digit, next 5 digit & rest. How to read those value
Need to select a specific numbers
Regex find
I want to get Work request number and ticket number using regex. please help
How to get match string or value by using Regex?
Email Body Extract
Extract certain string between "|"
Reverse different Language Words in an Excel Column
Getting text before first and second occurrence
Doubt with REGEX, I can't find the correct pattern
How to extract specific Text from notepad
The UiElement is no longer valid please solve the issue
Please help me on regex
Regex > Replace Multiple words from input string
New to Regex (Pattern)
How to get only particular field from pdf in UIpath
Take username from sharepoint link
Splitting text by 2nd appearance of word
Regex for in between Text
How to find URL with Regax
Which regex expression pattern to use if I want to select the number after 2 words?
Date extraction from PDF is not working!
Add folder in current directory
How To Split Text Using RegEx?
How to get the required output from given input using regex or trim or anything? Please help
Extract table from word to excel
Query IN Regex match
Specific body email
Split function with last tag as a new blank line
Extract information from downloaded E-mails
I have text file and I have around 100 strings separated by , . I need to select a particular string and need to remove all strings before that particular string
How to find user input value in the pdf?
Select 1st or 2nd match while using regex based extractor and problem in regex expression for address
Extract email from a string
Dynamic Regex Build
I need to replace all the new line before a word in a XHTML document
How can we get multiple matches value from string and store in a variable from regex
PDF extraction from specific page only
Excel splitting a column value to multiple columns
Sorting files in directory by section of file name
Use regex 2
String manipulation - capture x items in list
Regex Match Help ( Assign: Object reference not set to an instance of an object)
RegEx specific digit after string
Split but using regular expressions
Remove rows length != 10 characters and replace 3rd last character from the rows if exists
Extraction of Number from String in the web browser
How to apply OR to regex
Calculate a discount with REGEX
String Operation to extract Email Id from a String
How to Split string in a new line
Regex to check if filename format was followed and extract number
Regex to fetch PDF Value
Regular Expression practice test
Mathes Emails with certain domen
Filing PDF's from email based on ABN Number
Studio: RegEx on a Web Application
Can't get selection value from list item from pdf
Get words starting with 0
String Capture
Need Regex code for my text
Get info from PDF
Get a part of string
How do I extract information from email subject Line
Regex - I want to retrieve the last word or number from a sentence
Retrieve specific word from subject line in Outlook
Splitting the large string
Regex pattern for knowledge
Extract substring from directory path between symbols
How to extract several smaller strings from a larger string?

@Steven_McKeering Really very helpful :hugs:


thanks for this valuable post. Bringing the SOP Pattern into the picture is a big plus and lets accelerate the answering activities to the upcoming RegEx questions here in the forum.




This is great! This will really help the community.


This is phenomenal and many will find it helpful.

Cheers @Steven_McKeering


Nicely done! Regexes can be difficult for people with and without developer backgrounds, and this is very helpful.


Hi @Steven_McKeering

I found this really great. It is very helpful for all of us along with beginners. Really appreciate. :innocent: :hugs: :love_you_gesture:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:



Nice post, It’s really useful


1 Like

@Steven_McKeering Awesome work. This post is a Gift to the Community now. All the required methods are presented in the best way possible to understand.

Yes, The SOP Pattern will bring a huge difference now and it will help the Community to provide a Solution really fast.

Thank you for providing such Great Informative Posts.



Great post! This helps Increasing quality of regex beginner’s posts.

1 Like

Awesome work! Let me move it to the official FAQ section! I love it.


Thank you. Just the SOP alone is a great help but you also give a lot of good practical tools to begin right away. Good job.

1 Like

Great Work buddy, This will help a lot!
Thank You

1 Like


Awesome work :clap: :clap: It’s really helpful to us. I bookmarked this post and will share with other community members if they face any issues or queries related to RegEx.


Hey @Steven_McKeering

This is amazing work bro… im sure this will be super helpful for the guys here who look for regex solutions.

Thank you so much for putting it up and for all your amazing efforts my friend… this is super cool work… i just bookmarked it too so I can easily access…

Keep it up man!!!


Its a wow article!! Cheers @Steven_McKeering

1 Like

Wow, amazing work @Steven_McKeering You are the best! I believe excellent Regex (and Excel/VBA) skills will bring you very far as an RPA developer.


Firstly, thank you everyone for your AMAZING :star_struck: response and support! :blush:

The secondary goal of this post was to make the forum ‘legends’ lives easier when responding to Regex forum posts. Time will tell whether this was achieved :crossed_fingers:

I have made many edits (50+) to the post at this stage to try and improve it a little bit. Hopefully I can add a few more examples that people find friendly. Your suggestions are always welcome.

  • Thank you to Pablito and @bcorrea for updating the category post/tags.
  • Big thank you again to Pablito for the adding the hyperlinks in the contents section. :raised_hands:
  • Thanks @msan for the detailed feedback :sunglasses:

I hope one day I will be able to contribute another valuable post to this great community on a different topic. I appreciate your support.

Happy Automation!

P.S - Send new users to @AndersJensen’s YouTube Channel. Anders is building a dedicated playlist for a full UiPath Beginners Tutorial.


That is one hellava post, thank you VERY MUCH!!!


@Steven_McKeering, Whoa!

This is awesome dude, thank you.