Skip to main content

Regular Expression (REGEX)

REGEX for App/Browser Automation

Regular Expression or REGEX is widely used to make searching/find characters in a string.

When you run a test on LambdaTest using a specific device, there may be scenarios, in which the particular device that you selected isn’t available. In these scenarios, REGEX will help you widen the search request for devices to run the test on.

To quote an example, consider you want to run the test on an iPhone. It doesn’t matter which one, but it’s got to be an iPhone. In these cases, we can use REGEX to specify exactly that. You’ll now be allotted any iPhone that’s available which widens the search of devices considerably.

.*The characters .* are used to include all the devices that match the string passed.

In the example given:
You’ll be allocated any device from the Inventory that’s an iPhone or a Pixel device respectively.

See detailed examples for using this RegEx here:
a) For iPhone:
b) For Pixel:
,This character , is used to include more combinations of different devices.

In the example given:
1. We have added 2 regex characters .* and , to show that using both in combination, we’ll fetch any device from the Inventory that contains the string Pixel, Nexus, Galaxy.
2. You’ll be allocated any available Pixel or Nexus or Galaxy device.
[]The [] is used to include special characters like + in the search. Not using the [] will prevent the special characters from being included in the search.

In the example given:
1. You’ll be allocated any Galaxy Note 10+.
2. Incase you send "Galaxy Note 10+" then, you’ll get Galaxy Note 10.
"Galaxy Note 10[+]"
[]The [] is used to include a range of devices in the combination mentioned using a single character only.

In the example given:
Fetching any device available from Pixel 3, Pixel 3a, Pixel 4, Pixel 5, Pixel 6, Pixel 6 Pro, etc.

See detailed examples for using this RegEx here:
“Pixel [3456]"
$The $ character indicates the end of a string.

In the example given:
1. Allocating only Pixel 6 device & will neglect the Pixel 6 Pro devices.
2. Allocating only the Pixel 3 device while neglecting Pixel 3a, Pixel 3 XL etc.

See detailed examples for using this RegEx here:
a) For Pixel 6:
b) For Pixel 6 & 3:
“Pixel 6$"
"Pixel [36]$"
^The ^ is used to negate a character from the search.

In the example given:
The first part of this regex .* includes all the OnePlus devices, whereas the second part [^8] neglects OnePlus 8, OnePlus 8 Pro devices as it contains the character 8, which is negated.

See detailed examples for using this RegEx here:

REGEX for XCUI & Espresso Tests

Platform version is not mandatory only if deviceName is passed using regex. If there is no regex in deviceName, passing platformVersion is mandatory.

Usual way to pass the deviceName and platformVersion looks like this:

"device" : [Pixel 6 Pro-12]

Passing deviceName using REGEX:

"device" : [Pixel.*-12]
Right way to pass REGEX:



REGEX is currently possible on the deviceName as of now and not on the platformVerison.

Got any questions?
Please reach out at our 24x7 Chat Support or you could also mail us at