Tools / Regex Workshop

Regex Workshop

JavaScript regex flavor, run in your browser. Matching runs in a background worker with a 1.5 second limit, so a runaway pattern is stopped instead of freezing the tab. Nothing is uploaded or saved to a server.

Pattern

//
Share link (includes your text), save, download, whitespace

Test text

What is inside

Eight working parts, each one a tab or control you can use now.

Matches with position

Every match is painted onto your text in alternating grey tones, and listed with its number, line and column, index, length and text. Empty matches show as a marked position instead of vanishing.

Capture groups, numbered and named

Each match gets a column per numbered group ($1, $2) and one per named group (the name in angle brackets). A group that did not take part shows as undefined, not as an empty string, because they are different things in JavaScript.

Replace preview

Type a replacement using $1, $<name>, $&, $` , $' and $$ and read the exact output on your whole text before it touches a file. Copy the result with one button.

Split preview

See the pieces the pattern produces as a separator, including captured groups, which JavaScript keeps in the output. Splitting identifiers like parseHttpResponseCode at case changes is one of the library patterns.

Pass and fail cases

Write one case per line, + if the pattern should match it and - if it should not. The tab shows pass or FAIL per case and a total, and updates as you edit the pattern. This is how you keep a pattern honest after you tweak it.

Explain tab

The pattern is read left to right and described in plain words with nesting shown by indentation: classes, ranges, quantifiers (greedy or lazy), anchors, groups, lookahead and lookbehind, backreferences and unicode escapes.

A guard against runaway patterns

Matching runs in a background worker with a 1.5 second limit. A pattern like (a+)+$ on a long run of a is stopped with a message naming the likely cause, and the page stays usable.

Code, share and save

Copy equivalent code for JavaScript, Python, Java or PHP. Copy a share link that carries the pattern, flags and up to 4,000 characters of text; the page warns you it contains your text, and nothing is shared unless you press the button. Save the last 12 patterns in this browser. Download everything as JSON.

Worked examples

Real input, real output, from the tool itself.

Parse log lines into fields

Pattern ^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}) \[(\w+)\] (.*)$ with g and m on two log lines gives two matches. The first starts at index 0 with groups 2026-11-29, 09:00:01, INFO, started. The second starts at index 35 with 2026-11-29, 09:00:02, WARN, slow query. The "Log line" library entry loads this with its sample.

Reorder a date with named groups

Pattern (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) and replacement $<day>/$<month>/$<year> turns "Invoice 1042 was issued 2026-11-02" into "Invoice 1042 was issued 02/11/2026". This is the tool's default example, so you can see it the moment you open it.

Catch repeated words

\b(\w+)\s+\1\b with g and i on "This is is a test of the the backreference." finds "is is" at index 5 and "the the" at index 21. The \1 repeats whatever group 1 matched.

Split at case changes

(?<=[a-z])(?=[A-Z]) is a zero-width match. In the Split tab, parseHttpResponseCode becomes parse, Http, Response, Code. Lookbehind needs a modern browser; the tool warns you about older Safari.

Find a catastrophic pattern before production

(a+)+$ against forty a characters followed by an exclamation mark makes a backtracking engine try an exponential number of ways to fail. The tool stops it after 1.5 seconds and says so. a+$ says the same thing without nested repeats and returns at once.

Lock a pattern with cases

For ^[a-z0-9]+(?:-[a-z0-9]+)*$ write + good-slug, + also-ok-2, - Bad_Slug, - -nope. All four cases pass. Loosen the pattern later and any case that flips turns red.

Reference

The exact things the tool understands.

Flags

FlagNameWhat it changes here
gglobalFind every match. Without it you get the first match only.
iignore caseLetters match either case.
mmultiline^ and $ match at each line, not only the start and end of the text.
sdotAllThe dot also matches line breaks.
uunicodeTreats the pattern and text as unicode code points and enables \p{...} properties.
ystickyMatches only at the position where the previous match ended.

Replacement tokens

TokenInserts
$1 to $99The text captured by that numbered group.
$<name>The text captured by the named group.
$&The whole match.
$`The text before the match.
$'The text after the match.
$$A literal dollar sign.

Syntax from other flavors that the tool flags

JavaScript rejects or misreads these. The tool shows a note instead of leaving you with a silent mismatch.

You typedThe note says
(?>...)Atomic groups are not supported by JavaScript.
a++ or a*+Possessive quantifiers are not supported by JavaScript.
(?i)Inline flags are not supported. Use the flag switches.
\A \Z \zNot supported. Use ^ and $ with the m flag.
\hNot supported. Use [ \t].
(?P<name>...)Python-style named groups are not JavaScript syntax. Use (?<name>...).
\K, (?R), (?(Not supported by JavaScript.
[[:alpha:]]POSIX classes are not supported. Use [A-Za-z].
(?<=...)Works in current browsers; Safari before 16.4 does not support lookbehind.

How to use it well

A method that finds the bug before your users do.

Step 1

Paste real text, not a toy line. Edge cases live in real data: blank lines, trailing spaces, odd punctuation.

Step 2

Start small and broad, then tighten. Watch which matches disappear as you add constraints. Turn on "Show whitespace" when a match looks right but is off by an invisible character.

Step 3

Write cases for what must not match. Most bad patterns match too much, and a - case catches that.

Step 4

Read the Explain tab. If a token is described differently from what you meant, that is the bug.

Step 5

Check the runtime. Pick the language in the Code tab and test in that runtime, because lookbehind, unicode and \b differ between engines.

Step 6

Before you ship a pattern that runs on user input, try it on a long near-miss string. If the tool stops it, rewrite it without nested repeats.

What it cannot do

Limits, stated plainly.

One flavor: JavaScript

Matching uses your browser's JavaScript engine, so results are exactly what browser and Node code will do. It does not run PCRE, Python, Go, Java or .NET engines. The Code tab translates the pattern text and flags mechanically and says so in a comment at the top of each snippet. For the 24 library samples the Python and Java snippets find the same number of matches as JavaScript. The PHP snippet is not verified, and your own patterns can still behave differently, so test in the target runtime.

No step-through debugger

It tells you a pattern ran too long, not which branch backtracked.

No static ReDoS analysis

The guard is a time limit on your actual text. A pattern that is fast on your sample but slow on another input can still pass here.

Caps

Matching stops at 3,000 matches, the table lists the first 300, split shows up to 500 pieces, saved history keeps 12 entries, and share links and saved entries keep up to 4,000 characters of test text.

Explain describes syntax only

It does not predict what a pattern will match, and it does not cover every rare construct. If a construct is not recognized it is shown as a literal character.

Your data and your history

Saved history lives in this browser's local storage and is gone if you clear site data. A share link contains your test text in the address, so anyone who has the link can read it.

What it does

What it does.

Free JavaScript regex tester: live match highlighting with line and column, named-group tables, replace and split preview, pass/fail test cases, token-by-token explanation, a timeout against runaway patterns, code export and 24 starter patterns. It runs in your browser.

FunctionWhat it does here
JavaScript engine resultsYes, your own browser engine
Other engines (PCRE2, Python, Go, Java, .NET, Rust)No, code translation only
Highlighting, groups, replace, splitYes
Pass and fail casesYes, line-based
Step-through debuggerNo
Runaway-pattern protectionTime limit (1.5 s) on your text
Works with no account, nothing stored remotelyYes
ShareLink that holds your text in the address

Reading the result

What each readout means.

The status line

Shows the match count with your pattern and flags, for example "3 matches for /(?\\d{4})-.../g". Zero matches is a real result: check the flags and the test text before the pattern.

The match line

Under the highlighted text: how many matches, how many characters they cover, and how long the search took in milliseconds. A slow time on a short text can be a sign of a pattern that backtracks.

The Tests tab summary

"4 of 4 cases pass" counts your own pass and fail cases. A passing set only covers the cases you wrote, so add the awkward input you are afraid of.

Replace, Split, Explain, Code, Library

Each tab reuses the same pattern and flags. Replace and Split show what your pattern does to the text. Explain reads it token by token. Code writes it for other languages with the dialect caveat on that tab.

Common mistakes

Each of these is something the tool shows or warns about.

Greedy matching

<.+> on <a><b> matches the whole 6 characters as one match. <.+?> matches <a> and <b> separately. If a match swallows too much, try the lazy form.

Forgetting the g flag

Without g, \d on "1 2 3" finds one match. With g it finds three. The g button is on by default, so if you see only one match, check whether it was switched off.

Syntax from other regex flavors

(?P<name>...) from Python, inline flags like (?i), and possessive quantifiers like a++ are not JavaScript. The tool shows the engine error and a warning that names the JavaScript form to use instead.

Nested repeats that never finish

(a+)+$ against 40 letters a and an exclamation mark makes the engine retry an enormous number of paths. The tool stops after 1.5 seconds and says the pattern probably backtracks catastrophically, instead of freezing the page.

Lookbehind support

(?<=\$)\d+ works in current browsers. Safari before 16.4 does not support lookbehind, and the tool warns you to check the runtime you will ship to.

Sharing a link that holds your text

The share link contains your pattern, flags and up to 4,000 characters of your test text, readable by anyone with the link. The tool says so before it copies the link. Use example text for anything you will share.

Questions

Before you ask.

Is my text uploaded?

No. Matching runs in a worker inside your browser tab. The page makes no request with your text. Closing the tab clears it unless you saved to history or copied a share link.

Why did it say the pattern was stopped?

It ran longer than 1.5 seconds on your text. Nested repeats such as (a+)+ or (.*)* are the usual cause. Rewrite so each character can only be matched one way.

Why is a group shown as undefined?

In JavaScript an optional group that did not participate returns undefined, which is not the same as an empty string. The table shows the difference.

My PCRE or Python pattern fails here.

Look at the note under the pattern. It names the unsupported construct and the JavaScript way to write it, where there is one.

Does the g flag affect replace and split?

Replace in this tool replaces every match. Split always splits at every separator. The g flag controls the Matches tab.

What does it cost?

Nothing, and there is no account.

Your data

What stays on your device.

The tool runs in this browser tab. It does not need a server to do its job. Your pattern and test text stay in the page. Nothing is copied, downloaded or shared unless you press the button for it.

Try it

Paste your real text and try your pattern.

Open Regex Workshop
A wooden desk with glasses, a coffee cup, a plant and the edge of a laptop, banner image on the Regex Workshop page

Try it now.

Regex Workshop runs in your browser. No account needed.

Regex Workshop

See it at work

Test regular expressions with live highlighting, capture groups and replace previews.

Regex Workshop
Fields
API
CLI
pattern
flags
text
replacement
hiringsai tool regex-workshop
pattern string
flags g
text string
replacement string
4 fields, 1 required
curl -X POST https://hiringsai.com/api/v1/tools/regex-workshop/run
-d '{"input": {"pattern": "<text>"}}'
JSON result
hiringsai run regex-workshop --input '{"pattern": "<text>"}'
also callable over MCP
JSON result printed
Free toolAPI and MCPNo account
Fields
patternstring
flagsg
textstring
replacementstring
Ways to use it
pagethis app
APIPOST .../run
CLIhiringsai run
MCPtools/call
API call
POST /api/v1/tools/regex-workshop/run
input: {"pattern": "<text>"}
JSON result back
Command line
hiringsai run regex-workshop
--input <json>
JSON result printed
The Regex Workshop page as it opens
Regex Workshop4 fields
The page as it opens, captured from the live site.
The Regex Workshop app at phone width
Regex Workshopphone layout
The same app at phone width.
A laptop glowing in a dark room
Regex WorkshopFree tool
Test regular expressions with live highlighting, capture groups and replace previews.
A laptop showing a web search on a table
Regex WorkshopAPI and MCP
Call it from a script over the API or MCP.