Skip to main content
ToolsHub

Regex Tester

Write your regex pattern, paste test text, and see matches highlighted instantly. Supports flags, capture groups, and replace mode.

Updated

Files never leave your browser
//g
Common:

No matches yet

Enter a valid regular expression pattern and test string to see matches here.

How to use Regex Tester

The Regex Tester lets you write, test and debug regular expressions interactively against live sample text. It highlights all matches in real time, displays captured groups in a structured table and supports common regex flags such as global, case-insensitive, multiline and dotAll — making it an essential tool for validating patterns before embedding them in code.

  1. Enter your regular expression in the pattern field (without surrounding slashes).
  2. Select the flags you need: g (global), i (case-insensitive), m (multiline), s (dotAll).
  3. Type or paste your test string in the input area.
  4. Matches are highlighted inline and listed in the matches panel below.
  5. Expand any match row to inspect individual capture groups and their positions.
  6. Copy the working regex (with flags) to use directly in your code.

Your data never leaves your device — 100% private processing.

Understanding regex flags

Flags modify how the regex engine processes the pattern. The global flag (g) finds all matches rather than stopping at the first. The case-insensitive flag (i) makes letter comparisons ignore case. The multiline flag (m) makes ^ and $ match the start and end of each line instead of the entire string. The dotAll flag (s) makes the dot metacharacter match newline characters, which it normally excludes. Combining flags gives fine-grained control over matching behaviour.

Capture groups and named captures

Parentheses create capturing groups that extract sub-matches. For example, (d{4})-(d{2})-(d{2}) captures year, month and day from an ISO date string into groups 1, 2 and 3. Named captures (?<year>d{4}) assign a label, making patterns self-documenting. Non-capturing groups (?:...) group tokens without creating a capture, which improves performance and keeps group numbering clean.

Common regex syntax reference
TokenMeaningExample
.Any character except newlinea.c → "abc", "a1c"
\dDigit [0-9]\d{3} → "123"
\wWord character [A-Za-z0-9_]\w+ → "hello_1"
^Start of string/line^Hello → "Hello world"
$End of string/lineworld$ → "Hello world"
*Zero or moreab* → "a", "ab", "abb"
+One or moreab+ → "ab", "abb"
?Zero or one (optional)colou?r → "color", "colour"

Worked examples

Find all numbers

Inputs: pattern \d+ · flag g · text "Order 66 and 99"

Result: 2 matches: "66", "99"

Named capture group

Inputs: pattern (?<year>\d{4}) · text "2025-01-01"

Result: match "2025" · groups.year = "2025"

Lazy vs greedy

Inputs: pattern <.+?> on "<a><b>"

Result: lazy gives 2 matches: "<a>", "<b>"

Glossary

Regex
Regular expression — a pattern that describes a set of strings using special syntax.
Lookahead
A zero-width assertion (?=...) that matches a position followed by a specific pattern without consuming characters.
Lookbehind
A zero-width assertion (?<=...) that matches a position preceded by a specific pattern.
Quantifier
A token such as *, +, ?, {n,m} that specifies how many times the preceding element may appear.
Backreference
A token \1 that matches the same text previously matched by capture group 1.

Related reading

Free · No spam

Get weekly tool tips & updates

New tools, power-user tips, and productivity hacks — delivered free every Friday.

No spam, ever. Unsubscribe with one click.

Related Developer Tools

Explore all Developer Tools.