Editor
Waiting for input or regex execution…
Actions
Why Use This Regex Tester
- Real-time matching with an optional "live" mode to re-run as you type
- Structured match list with start index, end index, value and named capture groups
- Full JavaScript/ECMAScript RegExp syntax support (same engine as your JS runtime)
- Flag controls: g, i, m, s, u, y – combine and experiment safely
- Basic performance insight with per-run execution time in milliseconds
- Text-only summary output for quick copy/paste into tickets, docs or commit messages
- Excellent for learning: prototype patterns without running a full project or test suite
- Ideal for everyday tasks: log parsing, validation, URL / ID extraction, quick data cleaning
- Result list is softly capped to avoid UI freeze when matching large texts
🔧 How to Use the Regex Tester for regex-tester
1. Paste or Type Your Test Text
Add the text you want to search through: logs, snippets, CSV fragments, HTML, JSON, anything that’s plain text.
2. Write Your Regex Pattern
Enter the regular expression **without surrounding slashes**. For example: <code>\b\w+@\w+\.\w+</code> for a basic email-like pattern, or <code>(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})</code> with named groups.
3. Set Flags (g, i, m, s, u, y)
Toggle flags like <code>g</code> (global), <code>i</code> (case-insensitive) or <code>m</code> (multiline). Under the hood, the tester builds <code>new RegExp(pattern, flags)</code> exactly like JavaScript does.
4. Inspect Matches & Groups
Review each match with its index, optional end index and capture groups. Named groups appear as a JSON-like map so you can copy them into test fixtures, parsers or documentation.
5. Copy the Summary
Use the text summary as a quick report: it lists matches with indices and groups, ready to paste into tickets, code review comments or cheat sheets.
Regex Syntax & Engine Details
Character Classes & Basics
Core building blocks supported by the JavaScript RegExp engine.
| Pattern | Meaning | Example |
|---|---|---|
| . | Any character except line breaks (unless <code>s</code> flag) | <code>a.c</code> → matches <code>abc</code> |
| \d, \w, \s | Digits, word chars, whitespace | <code>\d+</code> → <code>123</code> |
| \D, \W, \S | Negated versions of the above | <code>\S+</code> → non-whitespace runs |
| [abc] | Character set | <code>[aeiou]</code> → a single vowel |
| [^abc] | Negated set | <code>[^0-9]</code> → non-digit |
| ^, $ | Start and end of input (or line with <code>m</code>) | <code>^Hello</code>, <code>!$</code> |
Quantifiers
Repetition of previous tokens, with greedy and lazy behavior.
| Pattern | Meaning | Example |
|---|---|---|
| ? | 0 or 1 time | <code>colou?r</code> → matches <code>color</code> and <code>colour</code> |
| * | 0 or more | <code>a*b</code> → <code>b</code>, <code>aaab</code> |
| + | 1 or more | <code>\d+</code> → <code>1</code>, <code>123</code> |
| {n} | Exactly n | <code>a{3}</code> → <code>aaa</code> |
| {n,} | At least n | <code>\d{3,}</code> → <code>123</code>, <code>1234</code> |
| {n,m} | Between n and m | <code>a{2,4}</code> → <code>aa</code>, <code>aaa</code>, <code>aaaa</code> |
Groups, Lookarounds & Named Captures
More advanced features provided by modern JavaScript engines.
| Feature | Syntax | Example |
|---|---|---|
| Capturing groups | (...) | <code>(\d{3})-(\d{2})</code> → area + suffix |
| Non-capturing groups | (?:...) | <code>(?:https?|ftp)://</code> |
| Backreferences | \1, \2, ... | <code>(\w)\1</code> → <code>aa</code>, <code>bb</code> |
| Lookaheads | (?=...), (?!...) | <code>\w+(?=! )</code> → word before <code>! </code> |
| Lookbehinds* | (?<=...), (?<!...) | <code>(?<=#)\w+</code> → text after <code>#</code> (*in modern engines) |
| Named groups | (?<name>...) | <code>(?<year>\d{4})</code> → <code>groups.year</code> in results |
Flags (Options)
The tester’s flags map directly to JavaScript RegExp flags.
| Flag | Name | Effect |
|---|---|---|
| g | Global | Find all matches instead of just the first |
| i | Ignore case | Case-insensitive matching |
| m | Multiline | <code>^</code> and <code>$</code> match line boundaries |
| s | DotAll | <code>.</code> also matches line breaks |
| u | Unicode | Enables Unicode mode and property escapes in modern engines |
| y | Sticky | Match at the current index only (used with <code>lastIndex</code>) |
Performance & Safety
The underlying JavaScript engine executes regex synchronously. To keep the UI responsive, the tester caps the number of collected matches (e.g. the first 500 hits in global mode). This helps avoid flooding the UI, but does not replace full performance audits for complex or critical patterns.
Command Line Regex Tools
Once your pattern works here, you can reuse the same or similar regex in your terminal, scripts or CI jobs:
Linux / macOS
Search with grep (extended regex)
grep -E 'pattern' file.txtFind lines that match a given pattern
Search & replace with sed
sed -E 's/pattern/replacement/g' input.txt > output.txtBatch substitutions in text files
Windows / PowerShell
PowerShell regex search
Select-String -Pattern '\d{3}-\d{2}-\d{4}' -Path logs.txtFind US-style SSN patterns in log files (example)
PowerShell regex replace
(Get-Content input.txt) -replace 'old', 'new' | Set-Content output.txtSimple regex-based replacements
Practical Regex Applications
Web & Frontend Development
- Validate emails, usernames, slugs or custom IDs in forms
- Extract route parameters from URLs or paths
- Quickly prototype patterns for client-side validation
// Basic email-like validation
/^[\w.+-]+@[\w.-]+\.[A-Za-z]{2,}$/i.test(email);// Route params: /post/123
const match = pathname.match(/^\/post\/(\d+)/);Logs, Data & Backend
- Parse timestamps and levels from log lines
- Normalize whitespace and clean messy text
- Extract IDs, emails or references from unstructured content
// Collapse repeated whitespace
const normalized = text.replace(/\s+/g, ' ').trim();// Simple log line matcher
const m = line.match(/\[(?<date>\d{4}-\d{2}-\d{2})] (?<level>INFO|ERROR): (?<msg>.*)/);Data Cleaning & Quick Scripts
- Strip unwanted HTML tags or attributes before parsing
- Pull all URLs, emails or IDs from a long blob of text
- Prepare dataset fields for import into another system
❓ Frequently Asked Questions
❓Why isn’t my regex matching anything?
., ?, +), 2) Forgetting the g flag when expecting multiple matches, 3) Missing anchors (^, $) or word boundaries (\b), 4) Using features your JavaScript engine doesn’t support yet (such as some lookbehinds). Try simplifying the pattern and adding pieces back gradually.⏱️What does the execution time (ms) mean?
performance.now(). The value is a rough single-run measurement of how long the regex took to execute on the current input. It’s useful for spotting obviously expensive patterns, but it’s not a full benchmark or a guarantee of production performance.🔍What’s the difference between first match and global mode?
g flag, JavaScript returns only the **first** match (if any). With g, the tester uses input.matchAll() to collect **all** matches (capped to a safe maximum), including indices and capture groups. Use global mode whenever you care about multiple occurrences.🌍Does this support Unicode and <code>\p{...}</code> escapes?
u flag to opt into Unicode mode, which unlocks things like \p{Letter} or \p{Script=Greek} in modern browsers and recent Node.js versions.⚠️Can this detect catastrophic backtracking?
Pro Tips
Build your regex in small pieces. Start with something simple that matches, then add anchors, groups and quantifiers step by step.
Use named capture groups (<code>(?<name>...)</code>) whenever possible. They make your matches self-documenting and much easier to read during code reviews.
Be careful with <code>.*</code> and nested quantifiers. They can cause heavy backtracking on large inputs. Make patterns more specific or limit repetition with <code>{n,m}</code>.
When debugging, temporarily remove the <code>g</code> flag and focus on the first match to simplify the mental model.
Additional Resources
Other Tools
- CSS Beautifier
- HTML Beautifier
- Javascript Beautifier
- PHP Beautifier
- Color Picker
- Sprite Extractor
- Base64 Decoder
- Base64 Encoder
- Csharp Formatter
- Csv Formatter
- Dockerfile Formatter
- Elm Formatter
- ENV Formatter
- Go Formatter
- Graphql Formatter
- Hcl Formatter
- INI Formatter
- JSON Formatter
- Latex Formatter
- Markdown Formatter
- Objectivec Formatter
- Php Formatter
- Proto Formatter
- Python Formatter
- Ruby Formatter
- Rust Formatter
- Scala Formatter
- Shell Script Formatter
- SQL Formatter
- SVG Formatter
- Swift Formatter
- TOML Formatter
- Typescript Formatter
- XML Formatter
- YAML Formatter
- Yarn Formatter
- CSS Minifier
- Html Minifier
- Javascript Minifier
- JSON Minifier
- XML Minifier
- Http Headers Viewer
- PDF To Text
- Serp Rank Checker
- Whois Lookup