Skip to content

Regex tester

Test a regular expression live when you extract or validate data in integrations. Pattern and text never leave your device; the pattern runs on a separate thread, so a pattern that backtracks catastrophically does not freeze the page but is stopped after one second.

Free tool · Integration

Just the pattern, without slashes (/…/). JavaScript (ECMAScript) syntax.

Flags

Without g only the first match is shown.

Refer to groups with $1 or $<name> and to the whole match with $&. If the field is empty, the preview is off.

Ready-made patterns

Pattern and text never leave your device; everything runs in the browser and nothing is sent or stored.

Write a pattern or pick one of the ready-made patterns to begin.

This is a JavaScript regex

  • A named group is written (?<name>…) in JavaScript; in Python it is (?P<name>…). Replacements use $<name>, $1 and $& (in PCRE/Python \1 or \g<name>).
  • Atomic groups (?>…) and possessive quantifiers (a++) do not exist in JavaScript, nor do inline flags such as (?i); flags are given outside.
  • \d, \w and \b are ASCII by default; for Turkish and other letters use the u flag and \p{L}.
  • . does not match line breaks (it needs the s flag); without the m flag ^ and $ are only the start and end of the text.

The result is that of the JavaScript engine. The engine you use in production (PCRE, Python re, Java, .NET, Go RE2) may behave differently; test the pattern in the target environment as well. The timeout guard protects the page in the browser, not your code on a server: if you will feed user input to a regex on a server, consider a length limit and a linear-time engine (RE2).

Would you like to build data extraction and validation rules into your integration flows safely? Let's design it together.

Request a call

01

How to use it

  1. A

    Write the pattern (or pick a ready-made example), tick the flags and paste the sample text.

  2. B

    See the matches, their positions and the capture and named groups in the highlighted text and the table.

  3. C

    If you like, write an expression with $1 or $<name> in the replacement field and preview the result.

02

Which regex dialect does this tool run?

The browser's own JavaScript (ECMAScript) regular expression engine. The syntax is shared by most languages, but there are differences: how named groups are written, atomic groups, inline flags and the form of replacement strings vary from language to language.

If you will carry the pattern to another language (Python, Java, .NET, PCRE), use the tool for a first test and then confirm it again in the target environment. The list below summarises the most common differences.

03

Catastrophic backtracking and the timeout guard

Some patterns, especially nested quantifiers (such as (a+)+$), try an exponential number of paths on an unsuitable text and can take seconds or even minutes. On the main thread the tab would freeze.

The tool runs the pattern in a separate Web Worker; if no answer arrives within one second the worker is terminated and a timeout is reported. The same pattern can eat CPU on your server too, so read the timeout message as a warning.

04

Flags, groups and replacement

g finds all matches, i ignores case, m makes ^ and $ line start/end, s lets the dot match line breaks too, u works with Unicode code points and y forces the match to the exact position searched.

Parentheses create a capture group and are numbered ($1, $2 …); (?<name>…) gives a name and (?:…) does not capture. In a replacement use $1, $<name> and $&; a group that did not match becomes empty text.

FAQ

Why does the dot (.) not match a line break?
In JavaScript the dot does not match line terminators by default. To match everything in multi-line text turn on the s flag or use [\s\S]. For ^ and $ you need the m flag; without it they are only the start and end of the text.
What does “timeout” mean, is my pattern wrong?
It means the pattern is valid but takes very long on this text; the usual cause is catastrophic backtracking from nested quantifiers (e.g. (a+)+, (.*)*). Rewrite the pattern to reduce ambiguity: do not nest quantifiers, keep alternatives apart and use more precise character classes where possible.
Why do I only see one match?
With the g flag off JavaScript finds only the first match. Tick g to see all matches. The same rule holds for replacement: without g only the first match is replaced.
How do I use named groups?
Write the pattern like (?<year>\d{4}); it appears by name in the table and is referred to as $<year> in the replacement. In Python the same group is (?P<year>…); you have to change the syntax when porting.
How do I extract GS1 application identifiers (AI)?
In the human-readable form with parentheses, such as (01)09506000134352(17)261231, the pattern \((?<ai>\d{2,4})\)(?<value>[^(]+) returns each AI and its value in named groups. In a raw GS1 string without parentheses the lengths depend on the AI; there you need to parse with the AI table and a regular expression alone is not enough.

Let's build your data extraction rules into your systems safely

We design rules for extracting, validating and transforming CRM, ERP, SCADA and logistics data inside integration flows. Let's talk through your current setup in a free discovery call.