Regex Tester

Build, replace, and test regex patterns — everything runs locally.

What this does & how to use it

Paste or type your test string, enter a regex pattern, and toggle flags (g, i, m, s, u, y). The tool instantly shows matches, a highlighted preview, and lets you replace or split text.

  • Matches lists each hit, index, and captured groups.
  • Replace shows output after applying your pattern and replacement.
  • Split breaks the text into parts wherever the pattern matches.
  • Highlighted shows the test string with matches wrapped in <mark>.
  • Use the Presets row for common patterns (emails, URLs, numbers, dates, Eircode, etc.).

Tip: If you want to see every match, include the g flag. For case-insensitive matching, add i.

Flags:
Type or paste sample text
Result after Replace with (or original if empty)
No matches

Use $1, $2… to reference capture groups.

[""," "," ",""]
Test 123 test

Matches are wrapped in <mark> for quick visual scanning.

Quick regex cheatsheet
Digit
\d
Any 0–9
Word char
\w
A–Z, a–z, 0–9, _
Whitespace
\s
Space, tab, newline
Start / End
^ $
Anchors (line start / end)
One or more
+
Previous token 1..∞
Zero or more
*
Previous token 0..∞
Optional
?
Previous token 0 or 1
Group / capture
( ... )
Saved as $1, $2…
Non-capturing
(?: ... )
Alternation
A|B
A or B
Character set
[abc]
Negated set
[^abc]
Escape
\.
Literal dot

Regex User Guide

What is a regular expression?

A regular expression (regex) is a compact pattern language for searching, extracting and transforming text. It’s supported across programming languages and tools.

How this tool works

  • Pattern — the regex you want to test (e.g. \d+).
  • Flags — modifiers such as g (global), i (ignore case), m (multiline), s (dotAll), u (unicode), y (sticky).
  • Test string — the input text. Results update as you type.
  • Matches — each match with index and any capture groups.
  • Replace / Split — preview replacements or split results immediately.

Common patterns (copy & paste)

Email
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[A-Za-z]{2,}
Simple, not full RFC validation.
URL
(https?:\/\/)?([\w-]+\.)+[\w-]{2,}(\/[\w./%#?=&-]*)?
HTTP(S) and bare domains.
Number (int/float)
\b\d+(?:\.\d+)?\b
Date (YYYY-MM-DD)
\b\d{4}-\d{2}-\d{2}\b
Irish Eircode
\b[A-Za-z0-9]{3}\s?[A-Za-z0-9]{4}\b
Loose match for routing key + unique identifier.
Collapse whitespace
\s+
Replace with a single space.

Flags reference

  • g — global (find all matches)
  • i — ignore case
  • m — multiline (^ and $ match line boundaries)
  • s — dotAll (. also matches newlines)
  • u — unicode mode
  • y — sticky (match starting at lastIndex)

Tips

  • Use ( ... ) to capture groups and reference them as $1, $2 in replacements.
  • Escape special characters with \ (e.g. use \. for a literal dot).
  • Start simple; add anchors ^ and $ to control where matches occur.

Regex FAQ

What is regex used for?

Cleaning data, validating inputs (emails, Eircodes), parsing logs, transforming text, and search/replace tasks in editors and code.

Why doesn't my pattern match?

Check escaping (\\. for a literal dot), anchors (^, $), and flags (i for case-insensitive, g for all matches).

Does this support Unicode?

Yes — enable the u flag for Unicode mode.

How do I replace with capture groups?

Use $1, $2, etc. in the Replace with input.