A laptop, a phone and a hand writing in a notebook on a wooden desk, banner image on the Regex Workshop page

Ferramentas / Build suite

Regex Workshop

Write a regular expression, see it work on your own text, and know it is safe before it ships.

A JavaScript regex tester that highlights every match, tables every capture group, previews replace and split, runs your pass and fail cases, explains the pattern token by token, and stops a runaway pattern instead of freezing your tab. It runs in your browser and uploads nothing.

Open the toolWhat is insideWhat it cannot do
Screenshot of the Regex Workshop tool

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.

Keep going

Other tools you may want next.

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.

Input To Output

Four editable inputs

PatternTest textReplacementPass and failcasesLive matchtableExplain viewCode exportsRegex WorkshopInOut
InPatternTest textReplacementPass and fail casesRegex WorkshopLive match tableExplain viewCode exportsOut
The pattern drives several views of the same test.

Spec Sheet

Six flag switches

g: globalselected at startiignore casemmultilinesdotAlluUnicodeysticky
g: globalselected at startiignore casemmultilinesdotAlluUnicodeysticky
The tool starts with the global flag selected.

Pipeline

A background matching run

Edit an inputDebounce for 120msSend identifiedworker jobIgnore stalerepliesRender the result
Edit an inputDebounce for 120 msSend identified worker jobIgnore stale repliesRender the result
Matching runs outside the page thread.

Bar Compare

Timing in milliseconds

Input debounce120 msWorker timeout1500 ms
Input debounce120 msWorker timeout1500 ms
The debounce waits before starting. The safety timer ends an unresponsive worker.

Bar Compare

Different result ceilings

Collected matches3000 itemsVisible match rows300 itemsSplit pieces500 items
Collected matches3000 itemsVisible match rows300 itemsSplit pieces500 items
Matching, table display and split output have separate limits. These are not test-text length limits.

Pipeline

If a worker stalls

Safety timer firesTerminate workerDiscard workerhandleShow timeoutmessageClear stale resultviews
Safety timer firesTerminate workerDiscard worker handleShow timeout messageClear stale result views
A timed-out worker is discarded. A later run can create another one.

Pipeline

Invalid patterns fail visibly

Build regularexpressionCatch syntax errorReturn errormessageRestore unmarkedtextClear prior resulttables
Build regular expressionCatch syntax errorReturn error messageRestore unmarked textClear prior result tables
Constructor errors are caught inside the worker.

Before After

Visible whitespace

Source textWith whitespace marksSpaceTabNewlineMiddle dotRightwards arrowReturn mark
Source text to With whitespace marksSpaceMiddle dotTabRightwards arrowNewlineReturn mark
The whitespace toggle changes rendering, not the source text.

Before After

Reorder a date by named groups

Input partsOutput partsyear group: YYYYmonth group: MMday group: DDday reference: DDmonth reference: MMyear reference: YYYY
Input parts to Output partsyear group: YYYYday reference: DDmonth group: MMmonth reference: MMday group: DDyear reference: YYYY
The replacement refers to group names rather than hard-coded positions.

Pipeline

Replacement preview

Reuse the patternRemove stickybehaviorApply globalreplacementRender escapedresultCopy result ifrequested
Reuse the patternRemove sticky behaviorApply global replacementRender escaped resultCopy result if requested
The replacement operation uses a separate global expression.

Pipeline

Split preview

Reuse the patternRemove global andsticky flagsSplit up to thepiece ceilingNumber the piecesMark empty andundefined
Reuse the patternRemove global and sticky flagsSplit up to the piece ceilingNumber the piecesMark empty and undefined
Split uses its own expression and preserves empty or undefined pieces in the table.

Before After

Write executable test cases

Input partsOutput partsPlus-prefixed caseMinus-prefixed caseExpected matchExpected no match
Input parts to Output partsPlus-prefixed caseExpected matchMinus-prefixed caseExpected no match
Unmarked lines are ignored. Each marked line has its own expected boolean.

Spec Sheet

Explain quantifiers

*zero or more+one or more?zero or one{n}exactly n{n,}n or more{n,m}between n and m
*zero or more+one or more?zero or one{n}exactly n{n,}n or more{n,m}between n and m
The Explain view recognizes these repeat forms and their lazy variants.

Pipeline

Explain reads the pattern left to right

Read the nexttokenIdentify its kindEmit aplain-languagelineIndent by groupdepthAdvance to thenext token
Read the next tokenIdentify its kindEmit a plain-language lineIndent by group depthAdvance to the next token
The explainer is a sequential parser, not a prettifier.

Spec Sheet

Explain escapes

\d \w \sdigit, word, whitespace\D \W \Sthe negations\b \Bboundary / not\n \r \tnewline, return, tab\f \v \0form feed, vertical tab, null\u0041 \x41unicode and hex\p{L} \P{L}property / inverse\k<n> \1backreferences
\d \w \sdigit, word, whitespace\D \W \Sthe negations\b \Bboundary / not\n \r \tnewline, return, tab\f \v \0form feed, vertical tab, null\u0041 \x41unicode and hex\p{L} \P{L}property / inverse\k<n> \1backreferences
The escape lookup covers the simple forms; the advanced forms are parsed as separate branches.

Spec Sheet

Warn about foreign syntax

(?>...)atomic groupa++possessive quantifier(?i)inline flags\A \Z \z \h \Kunsupported escapes(?P<name>)Python group spelling(?R) (?0) (?&recursion(?(...)conditional groups[[:alpha:]]POSIX classes
(?>...)atomic groupa++possessive quantifier(?i)inline flags\A \Z \z \h \Kunsupported escapes(?P<name>)Python group spelling(?R) (?0) (?&recursion(?(...)conditional groups[[:alpha:]]POSIX classes
These are pattern checks, not a full compatibility proof.

Pipeline

JavaScript code output

Escape literalslashesGlobal flag:matchAll loopOtherwise a singleexecAppend a replaceexample
Escape literal slashesGlobal flag: matchAll loopOtherwise a single execAppend a replace example
The code view uses the same browser engine as the live matcher.

Spec Sheet

Examples have explicit limits

Emailfinds text, not existenceISO dateno month-length checkHTML tagnot an HTML parserPhoneno area-code checkCard-like digitsno card validation
Emailfinds text, not existenceISO dateno month-length checkHTML tagnot an HTML parserPhoneno area-code checkCard-like digitsno card validation
The library is not a set of universal validators.

Before After

Java and PHP exports differ

Java exportPHP exportPattern plus Matcher loopFlags as Pattern constantsSlash-delimited patternFlags as modifier letters
Java export to PHP exportPattern plus Matcher loopSlash-delimited patternFlags as Pattern constantsFlags as modifier letters
Neither export is executed by this page.

Pipeline

Translate to Python

Respell namedgroupsMap i, m, s flagsNote u and y haveno equivalentLoop with finditerTranslate or flagreplacement tokens
Respell named groupsMap i, m, s flagsNote u and y have no equivalentLoop with finditerTranslate or flag replacementtokens
Named groups, flags and replacement syntax are respelled; unsupported replacement tokens are flagged rather than silently kept.

Input To Output

JSON export keeps analysis data

CurrentsessionPattern,flags, flavorText,replacement,casesMatch indexand textNumbered andnamed capturesJSON exportInOut
InCurrent sessionJSON exportPattern, flags, flavorText, replacement, casesMatch index and textNumbered and named capturesOut
The download is separate from history snapshots.

Pipeline

Two ways back to a session

History: newesttwelve snapshotsStored in thisbrowser onlySnapshot: encodedinto a linkAnyone with thelink can read itRestore inputs onopen
History: newest twelve snapshotsStored in this browser onlySnapshot: encoded into a linkAnyone with the link can read itRestore inputs on open
History stays in this browser; a share link carries one snapshot to anyone who opens it.