Skip to content
MyToolkit.pro

Text & lists

Regex Tester

Type a regular expression and see every match light up in your text. Add flags like g, i or m, read a plain-language error when the pattern is broken, and copy a tidy match report. Your text stays in this browser.

Private by design: no text is uploaded or stored.

Pattern and test data

Operation
Flags

Any of g (global), i (ignore case), m (multiline), s (dotall), u (unicode), y (sticky).

Maximum 100,000 characters and 500 matches per run.

Engine: JavaScript RegExp in your browser. Syntax may differ from PCRE, Python, or RE2.

Try an example

Result

Updates when you test or change the pattern.

0Matches found

Matches in your text

Matches and capture groups

#ValueTypeStartEnd

How does the regex tester work?

The pattern is compiled by the JavaScript RegExp engine in your browser. Matches and capture groups show their zero-based start and end offsets. Replace mode supports JavaScript tokens such as $1 and $&. Nested unbounded quantifiers are refused because they can freeze a browser through excessive backtracking.

How to test a JavaScript regex against your own text

  1. Type the pattern into Regular expression without the surrounding slashes. The field already shows them, so \d+ is enough; /\d+/ would look for literal slashes.
  2. Choose flags. Only g is on by default. Leave it on if you want every match, because without it the tester stops after the first one.
  3. Paste your sample into Test text. Results update as you type, and the Test button below the field re-runs the pattern straight away.
  4. Read the result panel. The counter shows how many matches were found. The preview highlights them in place, and the table lists each whole match with its capture groups underneath.
  5. To try a substitution, switch the mode toggle at the top of the form from Test to Replace and type a replacement string. The rewritten text appears in the replacement preview, and your original input is left unchanged.
  6. Press Copy report to copy a plain-text summary that you can paste into a code review, ticket or chat.

Example patterns and the reports they produce

Named groups are labelled in the report, so you can check that each part of a pattern captures what you expect. Pattern (?<year>\d{4})-(?<month>\d{2}) with flag g on the text Due 2026-10 and 2027-01:

2 matches
#1: 2026-10 [4–11]
  group 1 <year>: 2026 [4–8]
  group 2 <month>: 10 [9–11]
#2: 2027-01 [16–23]
  group 1 <year>: 2027 [16–20]
  group 2 <month>: 01 [21–23]

An optional group that does not take part in a match is marked as unmatched. It is not shown as an empty string. Pattern colou?r(s)? with flags gi on Color, colours:

2 matches
#1: Color [0–5]
  group 1: — unmatched
#2: colours [7–14]
  group 1: s [13–14]

Flags change the result in ways that are easy to miss:

Pattern Flags Text Matches
^\w+ g one two / three four (two lines) one
^\w+ gm same two lines one, three
\p{Lu} gu Łódź and Zürich Ł, Z
\p{Lu} g Łódź and Zürich none

Without u, \p{Lu} does not raise an error. It silently matches the literal text p{Lu} instead, so it finds nothing in normal prose. Turn on u whenever you use \p{…} escapes or work with emoji.

Rewriting text in Replace mode

Replace mode uses the same rules as JavaScript's String.prototype.replace. With pattern (\d{4})-(\d{2})-(\d{2}), flag g and the replacement $3.$2.$1, the text 2026-10-22, 2027-01-05 becomes 22.10.2026, 05.01.2027. Turn g off and only the first date is rewritten: 22.10.2026, 2027-01-05. Before you paste the replacement into code, use the preview to check that every occurrence changed.

When the pattern works and you want to apply it to a longer document, continue in Find and Replace with its regular expression option turned on. It always replaces every match and ignores case unless you turn on Match case. The m, s and u flags are not available there, so a pattern that depends on them will behave differently.

Where this tester differs from PCRE, Python and server-side engines

The tester uses your browser's JavaScript RegExp engine. A pattern that passes here should behave the same way in JavaScript and TypeScript code (in browsers or Node.js). Other languages may handle it differently:

  • Inline modifiers: PCRE and Python accept (?i) at the start of a pattern. JavaScript rejects it, so use the i flag instead. Newer browsers also accept the scoped form (?i:…), but older engines report it as an invalid group.
  • Possessive quantifiers and atomic groups: a++ and (?>…) from PCRE are syntax errors in JavaScript.
  • RE2 (used by Go and some databases): lookarounds and backreferences that pass here are rejected by RE2.
  • Size limits: the pattern can be up to 500 characters and the test text up to 100,000 characters. Matching stops after 500 matches, only the first 50 capture groups of each match are listed, and the table shows at most 200 rows (whole matches and groups combined). For large data sets, test a representative sample.

Patterns where a repeated group already contains +, * or {n,} are refused before they run, for example (a+)+ or (\w+\s?)*. Replace the repeated group with a character class: [\w\s]+ covers the same run of words and spaces and runs without the warning. The full JavaScript syntax reference is on MDN: Regular expressions.

Frequently asked questions

How do I match any character including a newline?

The dot does not match line breaks by default, so a.b finds nothing when a newline sits between a and b. Turn on the s flag, or use [\s\S] in place of the dot if your code cannot set flags.

What do $& and $<name> mean in a regex replacement?

$& inserts the whole match and $<name> inserts a named group. With \d+ and the replacement [$&], Order 12, order 34 becomes Order [12], order [34]; with (?<y>\d{4})-(?<m>\d{2}) and $<m>/$<y>, Due 2026-10 becomes Due 10/2026.

Why does the tester show ∅ or matches with zero length?

Your pattern can match an empty string, so it succeeds at positions where nothing is consumed. \d* on a1 gives three matches: an empty one at 0, 1 at 1–2 and another empty one at 2. Use + instead of * when you need at least one character.

How do I match a literal dot, bracket or question mark in a regex?

Escape it with a backslash: \., \[, \? or \(. Unescaped, 3.50 also matches 3x50, while 3\.50 matches only 3.50.

All in Code & Data

Find and Replace

Find and replace text with options for case sensitivity, whole words and regular expressions. Works entirely in your browser.

Text & Lists In your browser

Hash Generator

Generate MD5, SHA-1, SHA-256 and SHA-512 hashes of any text in your browser. Digests update instantly and nothing is uploaded.

Code & Data In your browser

Keyword density checker

Count keyword frequency and density locally with configurable stop words.

Text & Lists In your browser

JSON Formatter

Format, validate and beautify JSON data privately in your browser.

Code & Data In your browser

Text readability estimator

Estimate English or Polish text readability locally with transparent sentence, word and syllable metrics.

Text & Lists In your browser

JWT Decoder

Decode a JSON Web Token (JWT) in your browser. Read the header and payload claims, see the algorithm and claim count. Nothing is uploaded and the signature is not verified.

Code & Data In your browser

What do you need?

Swipe up for the next one