How to Test Regular Expressions Online (Free)
Regular expressions are powerful but notoriously tricky to write correctly. Testing them against real data with immediate visual feedback is the fastest way to build them right. This guide walks you through using the browser-based Regex Tester to write, debug, and confirm your patterns — with live highlighting and capture group display.
Step-by-Step Instructions
Open the Regex Tester
Go to the Regex Tester tool. The interface has three inputs: the pattern field, the flags field, and the test text area.
Enter your regex pattern
Type your pattern in the Pattern field — without the surrounding forward slashes you'd write in code. For example, to match email addresses, enter: [a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}
Set your flags
Enter flags in the Flags field. The most common flags are: g (global — find all matches, not just the first), i (case-insensitive), m (multiline — ^ and $ match line starts/ends), and s (dotAll — makes . match newlines too).
Paste your test text
Paste the text you want to match against in the large text area. All matches are highlighted in yellow in real time as you type the pattern — no need to click a button.
Read the match count
Below the text area, the total number of matches is shown. If the pattern has errors (unbalanced parentheses, invalid syntax), the error message from JavaScript's RegExp constructor is shown instead.
Inspect capture groups
If your pattern has capture groups (parenthesized subpatterns), they're listed below the match count. Named groups (using ?<name> syntax) are shown with their names. This is useful for verifying that specific parts of the pattern captured the value you expected.
Essential Regex Flags Explained
g— Global. Without this, the pattern matches only the first occurrence. Almost always what you want for testing.i— Case-insensitive. Makes uppercase and lowercase equivalent.hellomatches "Hello", "HELLO", "hElLo".m— Multiline. Makes^match the start of each line (not just the entire string) and$match the end of each line.s— DotAll. Makes.match newline characters. Without this,.matches any character except newline.
Named Capture Groups
Named groups use the syntax (?<name>pattern). They're useful when you want to extract a specific part of a match and refer to it by a meaningful name rather than a number.
For example, (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) extracts year, month, and day from ISO date strings. The Regex Tester displays all named groups alongside their matched values.