How to Extract Values Using Regex in UiPath
One advantage of regular expressions (regex) is that they can be used to detect the patterns of the data as well as extracting the required data from the input string statements. When these two things combine, they can be used for data extraction and automation. Any automation process that is good with regex finds a place. The pattern can be metadata, metadata, HTML, XML, or a JSON string. One key thing to understand about regular expressions is that they are a sequence of characters that create search patterns. They can be used as a replacement for the merge module in the combination of fetch and merge data.
What is Regex in UiPath?
Regular expressions, or regex for short, is a sequence of characters that form a search pattern. Regex will enable us to apply the concept of pattern matching and other youthful production values to this horrendous data structure.
It is possible to do this by searching, extracting, and manipulating text, in a very efficient and flexible way, way of working in Uipath. Regex is used within activities like Match, Is Match, and Replace for automating those processes which require text extraction or validation, among others.

How to Extract the Value Using Regex in UiPath
The most frequent method to extract values is to make use of the Matches activity, which returns a collection of matches those found in the string. In the below description, it is shown how to extract a value from a text string using regex in uiPath:
- Prepare the Text: First of all, you should make sure the string you are trying to extract values from is stored in a variable. You can take a look into the email, webpage, or file.
- Use the Matches Activity: The Matches activity is great for identifying a number of regex patterns that match the values. To configure it:
- Pull the Matches activity to the workflow.
- The Input property is thus set to the string you want to extract data from.
- The Pattern property will be the regex expression.
- The Result property is set to a variable of type IEnumerable<
- Access the Results: After engaging in the Matches activity, the matches will be saved in the result variable. You can employ the For Each activity to loop through the results and obtain separate match values.
As an instance, if you have a string The order number is 12345, and the total is $250.00., and you want to extract the order number and total value, then your regex pattern might be like this:
- Regex Pattern: \d+ (This pattern matches one or more digits)
The Matches activity would extract data items such as 12345 and 250 from the string and hence they can be used to perform the following actions.
How to Use Regex Builder in UiPath
UiPath has a Regex Builder built-in that helps you to create and test new regular expressions. This tool is especially useful for users who may not be familiar with regex syntax.
To use the Regex Builder in UiPath:
- Insert an Assign Activity: Firstly, add an Assign activity to your workflow.
- Launch the Regex Builder: In the Assign activity, find the Value field, and click on the ellipsis (…) to open the regex builder.
- Forming the Pattern: In the Regex Builder window, you:
- Add your regular expression as an input.
- Test it against the example data by putting a test string in the supplied box.
- Observe the segments of the test string that are matched and highlighted.
- Modify your regular expression if necessary until you get the correct matches.
- Insert the Regex Template: After you have completed crafting the pattern, you can then place this pattern in your automation workflow.

For instance, if you need to get email addresses from the text, you can say following the Regex:
- Regex Pattern
As an option, the Regex Builder is the tool for validation of your regular expression on some ordinary data sets before the parser workflow reveals errors or inconsistencies of your pattern.
How to Use Regex in Assign Activity in UiPath
The Assign activity is the main and widely used UiPath activity for the transition of data. The usage of regex in the Assign activity could be the key either to extract data or to send the data that is of different types. This is how you do it; here:
Extracting Data with Regex
One can glean a specific piece of information by regex from a line in which he/she matched certain strings and saved it in a variable. Suppose, the email address you target first is, let's say, the first email out of an in-text string.
- Prepare the Input String: For example, let's assume the input string is Please contact us at support@example.com for assistance.
- Set Up the Regex Pattern: In order to extract the email address, you can use this regex pattern:
- Regex Pattern
Apply the Assign Activity: You should use the following expression in the Assign Activity to get the first email in the Assign activity:

Conclusion
By leveraging the power of regex within UiPath, you can easily automate text extraction, data validation, and data transformation tasks. You can begin developing patterns by creating Regex Builder, thus, the process becomes simple and easy to verify and test for the proper model.
Using regex in UiPath will solve the most sophisticated processing issues and thus, the automation workflows will be dynamic and more powerful.
Related Keywords:
- the regex method that extracts value in UiPath
- the regex bulky one in UiPath
- the use of regex for assignment in UiPath
Lucille
An effort offers a chance to learn, and a result provides valuable lessons.
