Regular Expression

Use this option to create a branch in the Pattern Matching step.

A Regular Expression is a pattern that matches the entire input text. If the pattern matches, the execution generates local variables in the branch for each group, such as $0, $1, $2, and so on up to $99, depending on how many groups the pattern contains. When you add the Pattern Matching step, $0 matches the input text value, namely $current.

When you select the plus sign to add a branch in the Pattern Matching step, the default Word Matching branch appears. Select Regular Expression from the Pattern Matching options.

Properties

Regular Expression

When using alternation patterns, such as a(.*)|(.*), the local variable may be created in the branch, but is left undefined. One of the groups ($1 or $2) is not used in the match.

We recommend that you check availability of the variables in the State pane.

If Ignore Case is selected, the pattern matching is not case-sensitive, meaning that the pattern is matched against the input without regard for character case.

Pattern

Click inside the box to open the editor and evaluate a regular expression. See Patterns.

Use the Sample Input box for testing purposes only.

If the execution is at the flow point before the Pattern Matching step, the default value is $current, but you can change it to anything without consequences for the robot.

Frequently used patterns

The following lists frequently used regular expression patterns. In RPA, we follow the syntax of Java regular expressions.

Working with the Pattern Matching step requires prior knowledge of regular expressions. Examples are provided for demonstration only.

To test your regular expressions, use a regular expression syntax checker, such as https://regex101.com/.

Pattern type

Description and input text example

Pattern example

Date

Matches a valid date in YYYY-MM-DD format.

2024-01-01

^(?:19|20)\d\d-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$

Email

Matches a valid email address.

name.lastname@mail.com

^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$

File extension

Matches common image and document file extensions, such as .jpg, .jpeg, .png, .gif, or .pdf

Filename.pdf

^.+\.(jpg|jpeg|png|gif|pdf)$

Fiscal year

Matches a valid date in MM/DD/YYYY format from 10/01/2023 to 9/30/2024.

01/02/2024

1[0-2]/\d?\d/2023|0?[1-9]/\d?\d/2024

IP address

Matches a valid IPv4 address in xxx.xxx.xxx.xxx format. Includes four groups of numbers separated by dots. Can range from 0 to 255.

01.234.0.255

^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$

Name

Matches a valid name in the "Last name, First name" format. Allows hyphens in the last name and underscores in both last and first name.

Smith-Anderson, John

([\w\-]+)\s*,\s*(\w+)\s*

Numeric input

Validates numeric input, including decimal and integer values.

1234.55

^\d+(?:\.\d+)?$

Password

Matches a valid password that is 8-24 symbols long, contains one lowercase and one uppercase character, and one special symbol.

myPassword12@

((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{8,24})

Phone number

Validates a phone number. Contains an optional "+" sign.

+123456789

^\+?[1-9]\d{1,14}$

Time in 12-hour format

Matches a time in 12-hour format. Contains AM or PM designation.

12:12 AM

^(1[0-2]|0?[1-9]):[0-5][0-9] (AM|PM)$

Time in 24-hour format

Matches a time in 24-hour format.

22:22

([01]?[0-9]|2[0-3]):[0-5][0-9]

URL

Matches a valid URL that starts with http or https.

https://www.tungstenautomation.com/

^(https?:\/\/)?([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})(:[0-9]{1,5})?(\/.*)?$

User name

Matches a valid user name that is 8-24 symbols long.

myusername_1

^[a-z0-9_-]{8,24}$