fileformer
search⌘KtranslateENexpand_moreupload_fileConvert
Converters8 file families · 44 direct conversions
What changes in a conversionarrow_forward
home/developer-tools/regex-tester

Free Regex Tester Online

Write a pattern. Watch it match, token by token.

Test JavaScript regular expressions against your own text. Matches light up as you type, capture groups are listed, and every part of the pattern is explained in plain English underneath.

//g
gglobaliignore casemmultilinesdot all
error
test text3 matches
Released 2026-09-29, updated 2026-10-03.Not valid: 2026-13-01 or 2026-02-30 or 29/09/2026
matches & groups
match 1index 92026-09-29$12026$209$329
match 2index 292026-10-03$12026$210$303
match 3index 662026-02-30$12026$202$330
the pattern, explained
\bword boundary (a position, not a character)(start capture group 1\ddigit 0-9{4}exactly 4 times)end of group-the character “-”(start capture group 20the character “0”[1-9]any one of: 1 to 9|or1the character “1”[0-2]any one of: 0 to 2)end of group-the character “-”(start capture group 30the character “0”[1-9]any one of: 1 to 9|or[12]any one of: 1, 2\ddigit 0-9|or3the character “3”[01]any one of: 0, 1)end of group\bword boundary (a position, not a character)
~/ready-made

Eight patterns people look up every day.

Each loads into the tester with sample text that includes a few near-misses, so you can see what it accepts and what it rejects. The note says where each one is too strict or too loose.

alternate_emailEmail address/[\w.+-]+@[\w-]+\.[\w.-]+/giPractical, not RFC-perfect: accepts most real addresses, rejects obvious junk.
markunread_mailboxUK postcode/\b[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}\b/giChecks the shape, not whether the postcode exists.
eventISO date/\b(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])\b/gGroups capture year, month and day. Still allows 30 February.
linkURL/https?:\/\/[\w.-]+(?:\.[a-z]{2,})(?:\/[^\s]*)?/giNeeds http(s)://. Add (?:https?:\/\/)? to accept bare www. addresses.
paletteHex colour/#(?:[0-9a-f]{3}){1,2}\b/giMatches 3- and 6-digit colours. It doesn’t accept the 4- or 8-digit forms that include transparency.
callUK mobile/(?:\+44\s?7|07)\d{3}\s?\d{6}/gAllows one optional space after the prefix; landlines are rejected.
tagHashtag/#[A-Za-z]\w{1,29}/gMust start with a letter; stops at 30 characters.
numbersPrice/£\d{1,3}(?:,\d{3})*(?:\.\d{2})?/gAccepts thousands separators and optional pence.
~/one-question-mark

Greedy grabs as much as it can. Adding ? makes it stop early.

The most common regex surprise: .+ runs to the last possible match, swallowing everything in between. Switch between the three versions to see what each captures from the same line.

<.+><.+?><[^>]+>
<b>Bold</b> and <i>italic</i> text
matches1first match<b>Bold</b> and <i>italic</i>behaviourgreedy
One match from the first < to the very last >, swallowing the text and every tag in between.
~/cheat-sheet

The building blocks, grouped by job.

Click any token to add it to the end of your pattern in the tester.

categoryCharacters\da digit\wword character\swhitespace.any character[a-z]one of a range
repeatQuantities+one or more*zero or more?optional{3}exactly 3{2,5}2 to 5
pin_dropPositions^start$end\bword edge(?=x)followed by x(?!x)not followed by x
data_arrayGroups( )capture(?: )group only(?<n> )named groupa|ba or b\1repeat group 1
~/catastrophic-backtracking

One extra character can double the time a pattern takes.

JavaScript, PCRE, Python and Java use backtracking engines. When a nested quantifier like (a+)+ fails to match, the engine tries every way of splitting the input between the inner and outer loop: 2ⁿ ways for n characters. This is the root of ReDoS outages. Press Run to time it in your browser on strings of growing length.

/^(a+)+$/exponentialNested quantifiers: the textbook ReDoS pattern./^(a|aa)+$/exponentialOverlapping alternatives: two ways to consume each pair of a’s./^(a|a?)+$/exponentialAn optional branch that overlaps the other branch./^a+$/linearThe same language as the first pattern, written without nesting.play_arrowRun /^(a+)+$/
/^(a+)+$/.test("aaa…a!")ms, measured here
111213141516171819202122
input length: n × “a” followed by “!”Not run yet. Each bar will be one real call to RegExp.test() in this tab; the run stops after 2.5 seconds of total time.
~/flavours

A pattern that works here may fail in Go, Python or grep.

There’s no single regex language. Go’s RE2 drops backreferences and lookaround to guarantee linear time; POSIX tools lack lazy quantifiers; JavaScript only gained lookbehind in 2018. The JavaScript column is tested live by compiling each example in this browser. Click a row to load it into the tester.

featureexamplePCRE2Python reJavaGo RE2POSIX EREJS · here
Lazy quantifiers/a+?/check_circlecheck_circlecheck_circlecheck_circlecancelcheck_circle
Lookahead/q(?=u)/check_circlecheck_circlecheck_circlecancelcancelcheck_circle
Lookbehind/(?<=\$)\d+/check_circlechange_circlechange_circlecancelcancelcheck_circle
Named groups/(?<year>\d{4})/check_circlecheck_circlechange_circlecheck_circlecancelcheck_circle
Backreferences/(\w)\1/check_circlecheck_circlecheck_circlecancelchange_circlecheck_circle
Unicode properties/\p{L}+/ucheck_circlecheck_circlecancelcheck_circlecancelcheck_circle
Atomic groups/(?>a+)b/check_circlecheck_circlecheck_circlecancelcancelcancel
Possessive quantifiers/a++b/check_circlecheck_circlecheck_circlecancelcancelcancel
Inline flag modifiers/(?i:abc)/check_circlecheck_circlecheck_circlecheck_circlecancelcheck_circle
Set operations/[\p{L}--[a-z]]/vcancelcancelcancelcancelcancelchange_circle
Recursion/a(?R)?b/check_circlecancelcancelcancelcancelcancel
check_circlesupportedchange_circledifferent syntax or partialcancelnot supportedJavaScript column: 8 of 11 compile in this browser
~/spec-sheet

JavaScript regex, for reference.

All eight flags defined by ECMAScript, each checked against this browser, plus the dates regular expressions changed, from Kleene’s notation to the v flag.

dindicescheck_circlehasIndices · ES2022Adds start and end positions for every capture group to each match.
gglobalcheck_circleglobal · ES3Find every match; exec() and test() then remember lastIndex between calls.
iignore casecheck_circleignoreCase · ES3Case-insensitive, using simple Unicode case folding with u or v.
mmultilinecheck_circlemultiline · ES3^ and $ match at the start and end of each line.
sdot allcheck_circledotAll · ES2018. also matches line terminators.
uunicodecheck_circleunicode · ES2015Treats the pattern as code points, enabling \u{…} and \p{…}.
vunicode setscheck_circleunicodeSets · ES2024Stricter u, with set subtraction, intersection and string properties.
ystickycheck_circlesticky · ES2015Matches only at lastIndex, for writing tokenisers.
StandardECMA-262 §22.2RegExp objects, with syntax in Annex B for legacy web compatibility
Literal/pattern/flagsOr new RegExp(string, flags); escape backslashes twice in strings
Engine typebacktrackingV8 adds an experimental linear-time engine for patterns without backreferences
Character modelUTF-16 code unitsCode points with the u or v flag
Lookbehindvariable widthUnusual among engines: JavaScript allows any length
Groupsnumbered · named$1: $99 in replace(); named via $<name> and match.groups
Escape helperRegExp.escape()Added in ES2025 for safely inserting user text into a pattern
Related standardsPOSIX.2 · PCRE2 · UTS #18Unicode Technical Standard 18 defines Unicode regex levels
MIMEnonePatterns usually travel inside source code or JSON strings
1951Regular eventsStephen Kleene describes regular languages with the star operator.
1968Thompson’s editorKen Thompson compiles regexes to NFAs in the QED editor, then ed.
1973grepg/re/p becomes a standalone Unix tool.
1987PerlLarry Wall’s Perl makes regex central; later adds lazy quantifiers and lookaround.
1997PCREPhilip Hazel’s library brings Perl syntax to PHP, Apache and many others.
1999JavaScript regexES3 standardises RegExp with Perl-like syntax.
2010RE2Google releases a linear-time engine that rejects backreferences.
2018ES2018Lookbehind, named groups, the s flag and Unicode property escapes.
2024The v flagES2024 adds set notation and properties of strings.