Get Special Value from Text with Regex — Uipath

“Regex Expression” is a structure that helps us to get a number or any data from a literal text.
Let’s see with a simple example in this article.
Use “Assign” activity and create the “String” variable named “ExText” . And let’s write our text in front of it.

image

Then let’s throw an “Assign” activity again and enter the “Regex” against the “String” variable named “Result” .

image

  • System.Text.RegularExpressions.Regex.Match(StringValue, “Regex Expression”).ToString
  • System.Text.RegularExpressions.Regex.Match(ExText, “\d{6}”).ToString

Since we get a numeric value, you can specify that it is a digit with “\d” and indicate that it is a 6-digit number in the form of “\d{6}” .
If you type “\d” you will get the same result, but specifying it exactly may be more precise.
Let’s see the result with “Message Box”;

image

2 Likes