Build and test regular expressions in real time. Type a pattern, paste your test string, and see matches highlighted instantly. Toggle flags, inspect capture groups, and pull common patterns from the built-in library.
Pro tip: Start with a simple pattern and build up. Enable the
global flag (g) to find all matches, not just the first. Use the
explanation mode (subscribers) to decode what every token does.
How to Use the Regex Tester
Type or paste your regular expression in the Pattern field, then
paste the text you want to test against in the Test String area.
Matches are highlighted instantly. Toggle flags using the chips below the pattern:
g (global — find all matches), i (case-insensitive),
m (multiline — ^ and $ match line
boundaries), and s (dotAll — . matches newlines).
Understanding Regex Flags
Flags modify how the regex engine interprets your pattern. The global
flag is the most commonly needed — without it, the engine stops after the first
match. Case-insensitive makes /hello/i match
“Hello,” “HELLO,” and “hElLo.” Multiline
is essential when your test string contains line breaks and you want ^
and $ to anchor to each line, not just the entire string. DotAll
lets the dot metacharacter match newline characters, useful for patterns that span
multiple lines.
Capture Groups Explained
Parentheses in a regex create capture groups that extract specific
parts of a match. For example, (\d{3})-(\d{4}) matching
“555-1234” produces two groups: “555” and “1234.”
Named groups use the syntax (?<name>...) and make your regex
self-documenting. The match table shows all groups for every match, and subscribers
can see named groups in a dedicated panel.
Common Regex Patterns
The built-in pattern library includes ready-to-use expressions for everyday tasks: email validation, URL matching, phone numbers, IP addresses, dates, and more. Click any pattern to load it into the tester immediately. These patterns are production-tested starting points — you may need to adjust them for edge cases specific to your data format.
Reading the Pattern Explanation
Regular expressions can look cryptic even to experienced developers. The explanation
mode (available to subscribers) breaks your pattern into individual tokens and
describes each one in plain English. For instance, \b[A-Z][a-z]+\b
becomes: “word boundary, one uppercase letter A–Z, one or more lowercase
letters a–z, word boundary.” This makes it much easier to debug complex
patterns and understand regex you didn’t write yourself.
Tips for Writing Better Regex
Start simple and add complexity incrementally — test after every change. Use
character classes ([abc]) instead of alternation (a|b|c)
when possible; they’re faster. Prefer non-greedy quantifiers (*?,
+?) when you want the shortest possible match. Anchor your patterns
with ^ and $ when you need to match the entire string.
And always test with edge cases: empty strings, special characters, and inputs
longer than you expect.
Regex in Different Programming Languages
Most languages implement regex using PCRE (Perl-Compatible Regular Expressions) or a
close derivative, but there are meaningful differences that can break a pattern when you
move it between environments. Python’s re module supports verbose
mode (re.VERBOSE) for adding inline comments and whitespace, which is
invaluable for maintaining complex patterns. JavaScript historically lacked lookbehind
support in older engines, though modern V8 and SpiderMonkey have added it — if
you target older browsers, lookbehind assertions may not be safe to use. Go’s
standard regexp package uses RE2 semantics, which intentionally excludes
backreferences and some lookarounds to guarantee linear-time matching and prevent
catastrophic backtracking. Java and PHP can also diverge in how \s
handles Unicode whitespace characters. The safest approach is always to test your
pattern in the actual runtime environment of your target application, not just in a
browser-based tester.
Regex is often the right tool for scanning structured text, but for hierarchical data formats you will want purpose-built parsers — the JSON Formatter & Validator is a natural complement when you are extracting fields from JSON payloads. If you are working with encoded strings that need to be decoded before matching, the Base64 & Encoding Toolkit can handle that step first.