Online Regex Tester
Test and debug regular expressions in real-time with match highlighting, capture groups, substitution preview, and ReDoS protection. Runs entirely in your browser.
How to Use
The Online Regex Tester is a real-time debugging workbench for crafting, testing, and refining regular expressions directly in your browser. It highlights matches visually inside your test text, shows capture group details, and offers an optional substitution mode for find-and-replace workflows.
How to use this tool
- Enter a pattern: Type your regular expression between the slash delimiters. The pattern is evaluated as you type with results updating in real-time.
- Set flags: Click the flag buttons (
g,i,m,s,u) to toggle regex modifiers. Thegflag is enabled by default to find all matches. - Paste test text: Enter the text you want to match against. Matches are highlighted inline with color-coded backgrounds, and the match details panel shows indices and capture groups.
- Use substitution: Click "Substitution" to reveal the replacement field. Enter a replacement string using
$1,$2for capture groups or$&for the full match. The substituted output updates live. - Browse common patterns: Click "Common Patterns" to load a preset regex for emails, URLs, IP addresses, phone numbers, dates, and more.
- Explain your pattern: Click "Explain" to see a token-by-token breakdown of what each part of your regex does.
About This Tool
What Are Regular Expressions?
A regular expression (regex) is a sequence of characters that defines a search pattern. First formalized by mathematician Stephen Kleene in 1956 and implemented in Unix tools like grep in 1973, regular expressions have become an essential tool in every developer's workflow. Modern regex engines support features far beyond simple string matching: lookaheads, lookbehinds, backreferences, lazy quantifiers, and Unicode property classes enable precise text extraction and validation.
JavaScript RegExp Engine
This tester uses the browser's native JavaScript RegExp engine, which implements the ECMAScript specification. As of ECMAScript 2024, JavaScript regex supports named capture groups ((?<name>...)), lookbehind assertions ((?<=...) and (?<!...)), the dotall flag (s) which makes . match newline characters, and Unicode property escapes (\p{Letter}) via the u flag. The d flag for match indices and the v flag for set notation are also supported in modern browsers.
ReDoS Protection
Regular Expression Denial of Service (ReDoS) occurs when a poorly constructed pattern causes exponential backtracking. Classic examples include patterns like (a+)+$ matched against strings like aaaaaaaaaaaaaaaaaaaab. This tester protects against ReDoS by enforcing a strict 500-millisecond execution timeout and a 10,000-match ceiling. If your pattern triggers either limit, the tool aborts execution and displays a warning, preventing browser tab freezes.
Capture Groups and Backreferences
Capture groups (...) let you extract specific portions of a match. Each group is numbered from left to right starting at 1. Named groups (?<year>\d4) improve readability by assigning descriptive labels. Non-capturing groups (?:...) group without creating a capture, useful for applying quantifiers to alternations like (?:cat|dog)+. In substitution mode, reference groups with $1, $2, or $<year>.
Common Use Cases
Regular expressions are used for find-and-replace operations, input validation (emails, phone numbers, passwords), log file analysis, data extraction from unstructured text, URL routing in web frameworks, syntax highlighting in code editors, and web scraping pipelines. The Interactive Regex Cheatsheet provides a complete reference of all tokens and quantifiers.
Why Use This Tool
Private and Secure Testing
Testing regex patterns against production data or sensitive logs often means pasting private content into third-party tools. DevToolkit's regex tester runs entirely in your browser's local JavaScript engine. Your patterns and test strings never leave your device -- there are no network requests, no server-side processing, and no data retention. This makes it safe for testing against API keys, personally identifiable information, or proprietary data formats.
Real-Time Feedback Loop
The tool evaluates your regex as you type with sub-millisecond latency for typical patterns. Color-coded match highlighting in the test text area gives you immediate visual confirmation that your pattern captures exactly what you intend. The match details panel provides index positions and group captures, while the execution timer helps you identify performance-sensitive patterns before deploying them to production. Use the built-in JSON formatter to pretty-print extracted JSON data, or the Base64 encoder to decode matched Base64 strings.
Built-In Pattern Explanation
The pattern explanation panel parses your regex and describes each token in plain English. This is invaluable for understanding complex patterns written by others, debugging subtle matching issues, and learning regex syntax. Combined with the JSONPath tester for structured data queries, DevToolkit provides a complete text and data analysis toolkit.