Regex Tester
Test, debug, and understand regular expressions instantly.
Your regular expression and test data are processed entirely in your browser and are never sent to a server.
JavaScript RegExp engine · Browser runtime · Non-overlapping matches
✓ 4 matches found
Capture groups: 1Execution time: 0.59 ms4 matches found.
Match highlighting
Highlights mark full matches. JavaScript's standard matching returns non-overlapping matches. Lookahead-based patterns can sometimes be used for overlapping-match techniques.
Match details
Match #1
- Text
- over
- Index
- 26
- End
- 30
- Length
- 4
Capture groups
- Group 1: over
Named groups
- word → over
Match #2
- Text
- lazy
- Index
- 35
- End
- 39
- Length
- 4
Capture groups
- Group 1: lazy
Named groups
- word → lazy
Match #3
- Text
- Also
- Index
- 45
- End
- 49
- Length
- 4
Capture groups
- Group 1: Also
Named groups
- word → Also
Match #4
- Text
- 2026
- Index
- 51
- End
- 55
- Length
- 4
Capture groups
- Group 1: 2026
Named groups
- word → 2026
Replace
Supports JavaScript replacement tokens such as $&, $1, $<name>, and $$ where the engine allows them. Replace All uses global semantics (adds g when needed).
Original
The quick brown fox jumps over the lazy dog. Also: 2026-08-10 and hello world.
Replacement Result
The quick brown fox jumps [over] the [lazy] dog. [Also]: [2026]-08-10 and hello world.
\bWord boundary(?<word>Named capture group "word"\wWord character [A-Za-z0-9_]{4}Exactly 4 occurrences)End of group\bWord boundary
This is a maintainable explanation of common JavaScript regex constructs — not a full grammar parser. Complex tokens may be marked as advanced or unsupported.
Online Regex Tester & Debugger
Looking for a regex tester online, regex checker, or JavaScript regex matcher? Toolshelf helps you test regular expressions instantly — inspect matches, capture groups, named groups, and replacement results without uploading your data. Patterns run in your browser using the native JavaScript RegExp engine.
Whether you are validating emails, parsing logs, writing input checks, or learning regex syntax, this regex pattern tester shows what matched, where it matched, and why a pattern failed — privately and.
What you can do with this regex tester
- Test JavaScript regular expressions live in your browser
- Toggle g, i, m, s, u, y, and d flags with clear explanations
- Highlight matches safely inside the test string
- Inspect capture groups and named groups with indexes
- Try replacements with $1, $&, and $<name> tokens
- Load common pattern examples with realistic sample text
- Export match analysis as JSON — copy or download locally
- Private by design: regex and test data never leave your device
What is a regular expression?
A regular expression is a pattern that describes a set of strings. Instead of searching for fixed text, you can express rules like “one or more digits,” “an email-shaped token,” or “a date in YYYY-MM-DD form.” Regex appears in validation, search, log parsing, refactoring, and text cleanup.
What is a regex tester?
A regex tester lets you try a pattern against sample text and see matches immediately. A useful debugger also shows indexes, capture groups, replacement output, and clear errors when the pattern is invalid — so you can iterate without writing a throwaway script.
How to test a regular expression
- Enter your pattern in the Pattern field (flags stay separate).
- Toggle flags such as global (
g) or ignore case (i). - Paste a realistic test string that includes edge cases.
- Review highlighted matches, group values, and indexes.
- Optional: try a replacement string and copy the result.
JavaScript regex flags
g (global) — find all matches instead of stopping after the first.
i (ignore case) — match letters regardless of case.
m (multiline) — make ^ and $ apply per line.
s (dotAll) — allow . to match newlines.
u (unicode) — treat the pattern as Unicode code points.
y (sticky) — match only at lastIndex.
d (indices) — include start/end indexes for capture groups when supported.
Common regex patterns
The tool includes loadable examples for email, URL, IPv4/IPv6 (basic), phone numbers, dates, times, hex colors, usernames, whitespace, digits, UUIDs, domains, and more. Patterns labeled “basic” or “common validation” are practical approximations — not full RFC validators.
Regex quantifiers
Quantifiers control repetition: * (0+), + (1+), ? (0 or 1), {n}, {n,}, and {n,m}. Add ? after a quantifier for lazy matching.
Regex character classes
Shortcuts like \d (digit), \w (word character), \s (whitespace), and . (any character except newline unless DotAll) keep patterns short. Character sets [...] and negated sets [^...] define custom ranges.
Regex groups and capture groups
Capturing groups (...) store substrings for inspection and replacement. Non-capturing groups (?:...) group without storing. Named groups (?<name>...) label captures for clearer replacements with $<name>.
Lookahead and lookbehind
Assertions check surrounding text without consuming it: (?=...), (?!...), (?<=...), and (?<!...). They are powerful for password rules and contextual matches, but syntax and support can differ across languages — this tool follows JavaScript.
Common regex mistakes
- Forgetting to escape special characters like
.,*, or+. - Using incorrect anchors so the pattern matches more (or less) than intended.
- Confusing greedy and lazy quantifiers.
- Forgetting the global flag when you need every match.
- Building character classes that accidentally include or exclude dashes and ranges.
- Pasting PCRE/Python-only syntax into a JavaScript tester.
Regex flavor differences
This tool uses the JavaScript RegExp engine in your browser. Flavors such as PCRE, Python re, Java, .NET, Ruby, and Go differ in escapes, lookbehind rules, Unicode properties, and replacement syntax. A pattern that works elsewhere may fail here — and that is expected.
Frequently asked questions
- What is a regular expression?
- A regular expression (regex) is a compact pattern language for finding, validating, or replacing text. In JavaScript, patterns are executed by the built-in RegExp engine.
- How do I test a regex?
- Enter a pattern, choose flags, paste a test string, and review matches, indexes, and capture groups. Results update as you edit. You can also try replacements and load examples.
- What does the g flag mean?
- The g (global) flag finds all matches instead of stopping after the first. Without g, JavaScript typically returns only the first match.
- What does the i flag mean?
- The i (ignore case) flag makes matching case-insensitive, so Hello matches hello.
- What is a capture group?
- Parentheses (...) create a capturing group that stores the matched substring so you can inspect it or use it in replacements as $1, $2, and so on. (?:...) is non-capturing.
- What is the difference between greedy and lazy quantifiers?
- Greedy quantifiers like * and + match as much as possible. Lazy forms like *? and +? match as little as possible while still allowing the overall pattern to succeed.
- What is a lookahead?
- A lookahead asserts that text ahead matches (?=...) or does not match (?!...) without consuming characters. It is useful for password rules and conditional matching.
- What is a lookbehind?
- A lookbehind asserts that text behind the current position matches (?<=...) or does not match (?<!...). Support depends on the browser's JavaScript engine.
- Why is my regex not matching?
- Common causes include missing escapes for special characters, wrong anchors (^/$), needing the i or m flag, greedy quantifiers consuming too much, or using syntax from another regex flavor that JavaScript does not support.
- Can regex cause performance problems?
- Yes. Some patterns with nested ambiguous quantifiers can backtrack heavily and run slowly on certain inputs. This tool limits input size, caps rendered matches, and warns when execution takes unusually long.
- Is this Regex Tester private?
- Yes. Matching runs locally in your browser. Your pattern and test string are not uploaded to Toolshelf servers for processing.
- Does this tool support JavaScript regex?
- Yes. This is specifically a JavaScript RegExp tester. It does not claim PCRE, Python, Java, .NET, Ruby, or Go compatibility.
Related tools
Use cases
- For Developers — Format JSON, test regex, decode JWTs, and work with timestamps.
What would you like to do next?
Continue working with the next step in this workflow. Recently used tools in this set are listed first.
- Text Compare — Online text compare and diff checker.
- Text & Character Counter — Online text and character counter.
- JSON Formatter & Minifier — JSON formatter online: beautify, minify, and validate JSON in your browser.
- User-Agent Parser & Analyzer — Online User-Agent Parser and Analyzer.
Related guides
Short articles that explain the problem this tool solves.
- JavaScript Regex Cheat Sheet — A practical JavaScript regular expression cheat sheet covering flags, groups, anchors, and common patterns — with a link to test them live.
You may also need
Continue with related browser-based tools on Toolshelf.
- Text Compare — Online text compare and diff checker.
- Text & Character Counter — Online text and character counter.
- JSON Formatter & Minifier — JSON formatter online: beautify, minify, and validate JSON in your browser.
- User-Agent Parser & Analyzer — Online User-Agent Parser and Analyzer.
- JSON to CSV Converter — Online JSON to CSV converter.
- JWT Decoder & Inspector — Online JWT decoder and inspector.
- Hash Generator — Online hash generator.
- Chmod Calculator — Chmod calculator online.
Next steps
Related workflows on Toolshelf. These are curated paths, not usage rankings.
- Developer workflow — Format JSON, convert it to CSV, then inspect tokens.