Regex Tester
Type a pattern and some test text to see every match highlighted, with capture groups listed below. Uses the same JavaScript regex engine as Playwright and Cypress.
//
🔒 Runs entirely in your browser. Nothing you enter is sent to a server.
Regex cheat sheet for testers
| Token | Means | Example |
|---|---|---|
\d | Any digit | \d{3} matches 416 |
\w | Letter, digit or underscore | \w+ matches user_01 |
\s | Whitespace | a\sb matches "a b" |
^ $ | Start / end of text (or line with m) | ^EVT- |
[abc] | One of these characters | [A-Z] |
* + ? | 0+, 1+, 0 or 1 times | colou?r |
{n,m} | Between n and m times | \d{10,15} |
( ) | Capture group | (\d{4})-(\d{2}) |
a|b | Either a or b | confirmed|cancelled |
Where regex helps in QA
- Asserting dynamic text in UI tests, such as booking references, order numbers and timestamps.
- Checking the format of API response fields, such as IDs, emails and dates.
- Searching log files for errors, request IDs or stack traces.
- Writing input validation test cases: if you know the pattern, you know which values should fail.
Frequently asked questions
Which regex flavour does this tester use?
JavaScript (ECMAScript), the same engine used by Playwright, Cypress, Node.js and every browser. Most patterns also work in Java, Python and C#, but lookbehind and named-group syntax can differ slightly.
How do I use a regex in a Playwright assertion?
Pass a RegExp literal instead of a string, for example: await expect(page.getByTestId("booking-ref")).toHaveText(/^EVT-[A-Z0-9]{6}$/). Test the pattern here first, with the ^ and $ anchors.
Why does my pattern match only once?
Turn on the g (global) flag. Without it, JavaScript stops after the first match.