WebsOpener Tools
Regex Tester

Write, test, and debug regular expressions with live match highlighting, capture groups, and a built-in replace mode.

/
/
Enter a regular expression above
// test string
// matches
No matches yet — enter a pattern and test string above
// match info
Pattern—
Flags—
Total matches—
Groups—
Test length—
Coverage—
// replace
Replace output will appear here…
// regex cheatsheet ▼ show

Free Regex Tester | Test Regular Expressions Online with Live Match Highlighting

Stop guessing whether your regex works. Our free regex tester shows matches highlighted in real time as you type — with capture group colours, match positions, replace mode, and a full cheatsheet. No server, no delay, no page reload.


What Is a Regex Tester?

A regex tester is a tool that lets you write and test regular expressions against a sample string, showing which parts of the text match — live, as you type. It eliminates the trial-and-error cycle of running code just to see if a pattern works.

Regular expressions (regex) are sequences of characters that define a search pattern. They are used in every programming language for string matching, validation, parsing, search-and-replace, and data extraction. Writing them correctly the first time is notoriously difficult — which is exactly why a regex tester with live feedback is indispensable.

How to Use This Regex Tester

Step 1 — Enter your pattern Type your regular expression into the pattern field between the / delimiters. Matches highlight instantly in the test string below as you type — no button press needed.

Step 2 — Toggle flags Four flags control how your pattern behaves. g (global) finds all matches rather than stopping at the first. i (insensitive) makes matching case-insensitive. m (multiline) makes ^ and $ match the start and end of each line rather than the whole string. s (dotAll) makes . match newline characters too.

Step 3 — Paste your test string Type or paste any text into the test area. Every match is highlighted in red with an underline. The first match is highlighted more prominently. Capture groups are colour-coded across the match list.

Step 4 — Review matches The matches panel on the left lists every match with its index position, character length, and any capture group values. Click a match to jump to its position in the test area.

Step 5 — Use replace mode Type a replacement string into the Replace field. Use $1, $2 etc. for numbered capture groups, $& for the full match, or named group references like $<name>. The replaced output updates live.

Step 6 — Use quick patterns or the cheatsheet Twelve pre-built patterns cover the most common use cases — email, URL, IP address, date, hex colour, phone number, and more. Click any to load it with a sample test string. Open the cheatsheet at the bottom to click-insert any token directly into your pattern.

Understanding Regex Flags

g — Global: Without this flag, the engine stops after finding the first match. With g, it continues scanning the entire string and returns all matches. Most practical regex use cases require the global flag.

i — Case insensitive: Makes the pattern match regardless of letter case. /hello/i matches “Hello”, “HELLO”, and “hello”. Enabled by default in this tool.

m — Multiline: Changes the behaviour of ^ and $. Without m, they match only the very start and end of the entire string. With m, they match the start and end of each line, making it possible to process multi-line text line by line.

s — DotAll: The . character normally matches any character except a newline. With s, it matches newlines too — useful when your pattern needs to span across multiple lines.

Capture Groups Explained

Capture groups — written as (pattern) — extract specific parts of a match separately from the full match. When your pattern contains groups, each match in the results panel shows colour-coded chips for $1, $2, etc.

Named capture groups use the syntax (?<name>pattern). They make patterns more readable and allow you to reference groups by name in your replace string as $<name>.

Non-capturing groups — (?:pattern) — group a sub-pattern for quantifier purposes without creating a capture group. Use them when you need to group alternatives like (?:jpg|png|gif) but do not need to extract the value separately.

Lookahead and lookbehind — (?=pattern) and (?<=pattern) — assert that a match must be followed or preceded by something, without including that something in the match itself. For example, \d+(?= dollars) matches numbers followed by ” dollars” without including ” dollars” in the match.

Frequently Asked Questions

What is a regex tester? A regex tester is an online tool that lets you write regular expressions and test them against sample text, showing matches highlighted in real time. Our free regex tester supports all standard JavaScript regex syntax including capture groups, lookaheads, named groups, all four flags, and a built-in replace mode.

What does the g flag do? The g (global) flag tells the regex engine to find all matches in the string rather than stopping after the first one. Without g, your pattern will only ever return one match regardless of how many times it appears in the text.

How do I use capture groups in replace? In the Replace field, use $1 to insert the first capture group’s value, $2 for the second, and so on. Use $& to insert the entire matched string. For named capture groups like (?<year>\d{4}), use $<year>. For example, the pattern (\d{4})-(\d{2})-(\d{2}) with replacement $3/$2/$1 converts 2024-01-15 to 15/01/2024.

What is the difference between .* and .*?? .* is greedy — it matches as many characters as possible while still allowing the overall pattern to match. .*? is lazy — it matches as few characters as possible. For example, given <b>bold</b><b>text</b>, the pattern <b>.*</b> matches the entire string (greedy), while <b>.*?</b> matches <b>bold</b> and <b>text</b> separately (lazy).

Why does my regex work here but not in my code? The most common reasons are: a different flag set (check your code uses the same flags), a different regex flavour (this tool uses JavaScript regex — Python, PHP, and .NET have slight syntax differences), string escaping issues (backslashes need doubling in most language string literals — \\d instead of \d), or multiline mode differences.

What is the dotAll (s) flag? The s flag makes the . wildcard match newline characters (\n) in addition to all other characters. Without s, . stops at line breaks, which means patterns like <div>.*</div> will not match when the content spans multiple lines. With s, they will.

How do I match a literal dot, bracket, or other special character? Escape it with a backslash: \. matches a literal dot, \( matches a literal opening parenthesis, \[ matches a literal bracket. In JavaScript string literals you need to double the backslash: new RegExp("\\.").


More Free Tools from WebsOpener


No account required. No data stored. All processing happens locally in your browser.

Scroll to Top