Skip to content
DevToolKit

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.

//
Match Details

Enter a regex pattern to start matching

Was this tool helpful?

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

  1. Enter a pattern: Type your regular expression between the slash delimiters. The pattern is evaluated as you type with results updating in real-time.
  2. Set flags: Click the flag buttons (g, i, m, s, u) to toggle regex modifiers. The g flag is enabled by default to find all matches.
  3. 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.
  4. Use substitution: Click "Substitution" to reveal the replacement field. Enter a replacement string using $1, $2 for capture groups or $& for the full match. The substituted output updates live.
  5. Browse common patterns: Click "Common Patterns" to load a preset regex for emails, URLs, IP addresses, phone numbers, dates, and more.
  6. 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.

FAQ

What regex flavour does this tester use?
This tester uses the JavaScript RegExp engine built into your browser. It supports all ECMAScript 2024 features including named capture groups (?<name>...), lookbehind assertions (?<=...), the dotall flag (s), and Unicode property escapes (\p{...} with the u flag).
How does the ReDoS protection work?
The tester monitors execution time and automatically aborts any regex that takes longer than 500 milliseconds. It also caps the maximum number of matches at 10,000. This prevents catastrophic backtracking patterns like (a+)+ from freezing your browser tab.
Is my test data sent to any server?
No. All regex matching, substitution, and pattern analysis runs entirely in your browser using the native JavaScript RegExp API. Your patterns and test strings never leave your device.
How do I use capture groups in substitutions?
Use $1, $2, $3 etc. to reference numbered capture groups, $& for the full match, $` for text before the match, and $' for text after the match. Named groups captured with (?<name>...) can be referenced with $1 by position.
Can I test regex patterns for other languages like Python or Go?
The core regex syntax (character classes, quantifiers, groups, anchors) is shared across most languages. However, some features are language-specific: Python's re.VERBOSE mode, Go's RE2 restrictions on backtracking, and PCRE's recursive patterns are not supported. For standard patterns, results will be identical across languages.