Regex tester
Type a pattern and some text — matches highlight live, with capture groups listed below.
Building a pattern one piece at a time
The fastest way to a working regular expression is embarrassingly unglamorous: start by typing the literal text you want to find, watch it highlight, and only then generalise it step by step — swap the digits for a class like [0-9]+, allow optional parts with a question mark, anchor it with ^ or $ once the middle behaves. Because matches update live as you type, every small change gives you instant feedback, and a mistake shows up the moment you make it instead of three edits later. Just as important is what you paste in the text box: include lines the pattern should not match, not only the ones it should. A pattern tested purely against happy examples has a habit of matching half the document the moment it meets real data.
Capture groups do the extracting
Wrap part of a pattern in parentheses and it becomes a capture group — the piece of each match you actually want to keep. A pattern like ([0-9]{2}):([0-9]{2}) run against a page of text does not just find times; the table below the text lists each match with group one holding the hours and group two the minutes, plus the position where it was found. Add the g flag and you collect every occurrence in the text instead of stopping at the first. This is the honest core of most everyday regex work: not clever validation, but pulling structured values — dates, order numbers, prices — out of text that was never meant to be structured.
When a pattern hangs — and the safety net
Some patterns are traps. Nest one open-ended quantifier inside another — the classic shape is (a+)+ — and on the wrong input the engine tries an exponential number of ways to split the text before giving up. On most sites that freezes the whole tab; here the matching runs off in a background worker that is stopped after two seconds, so you get an explanation instead of a dead page. The cure is almost always to make the pattern more specific, so the engine has fewer ways to carve up the same text. One honest caveat: this tester uses JavaScript's engine, which is ideal if the pattern is destined for a script or webpage, but Python and PCRE differ on a few constructs — test in the final language too. When the values you extract are destined for a link or a query string, the URL encoder is the natural next stop.
How this tester works
Your pattern runs against the text using JavaScript's own regular expression engine — the same one your code will actually use if this is for a script or webpage. Matches are highlighted in the text and listed with their capture groups below.
Which flags are supported?
Any flag JavaScript accepts works here. In practice you will mostly use g (global — find all matches, not just the first), i (case-insensitive) and m (multiline, so ^ and $ match line boundaries) — the ones you'll use in practice.
Why does my pattern show an error?
JavaScript's regex syntax has a few differences from other languages (PCRE, Python) — an unescaped special character or an unsupported construct will throw a syntax error, shown directly instead of a silent wrong result.
Is my text sent anywhere?
No — matching runs entirely in your browser with plain JavaScript. Nothing is uploaded.
