Free Online Regex Tester — Five Regex Tools in One
This page gives you five browser-based regex utilities in one place. Every tool runs entirely in your browser using the JavaScript RegExp API. Nothing you type is sent to a server, no account is needed, and there is no software to install. Select a tool from the left sidebar, enter your pattern, and results update in real time.
Regex Tester
Paste any text and see every match highlighted inline. Set the g, i, m, and s flags with toggle buttons and watch the count update instantly.
Regex Replace
Enter a pattern, a replacement string, and input text to see the result immediately. Captured group references like $1 and $2 are fully supported.
Match Extractor
Lists every match with its character index and any capturing group values. Export results as a plain text file with one match per line.
Regex to JS
Generates a ready-to-paste JavaScript snippet with .test(), .exec(), .matchAll(), .replace(), and .split() examples built around your pattern.
Cheat Sheet
A quick reference covering anchors, character classes, quantifiers, groups, lookarounds, flags, and common real-world patterns.
Online Regex Tester with Match Highlighting
The Regex Tester tool takes a regular expression pattern and a block of test text and highlights every match directly inside the text. The match count appears in the output header so you can see at a glance whether your pattern is too broad, too narrow, or exactly right. The pattern and text areas are separated by a draggable divider so you can resize either side to fit your content.
How the Flags Work
Four flags are available as toggle buttons in the toolbar. The g flag enables global matching so all occurrences are found rather than just the first. The i flag disables case sensitivity. The m flag changes the behavior of ^ and $ so they match the start and end of each line in a multiline string. The s flag makes the dot match newline characters, which is useful for patterns that need to span multiple lines.
Regex Error Feedback
If the pattern you enter is not valid JavaScript regex syntax, a red error bar appears immediately below the toolbar with the exact error message from the browser's regex engine. Common causes include unescaped special characters, mismatched parentheses, invalid quantifier ranges, and unsupported syntax for the JavaScript flavor. The error bar disappears as soon as the pattern becomes valid.
Free Regex Replace Tool Online
The Regex Replace tool performs a find-and-replace operation on your input text using the regex pattern and the replacement string you provide. The output text appears in the right pane and updates automatically as you type. You can copy the result to your clipboard or download it as a text file.
Using Captured Groups in Replacements
Parentheses in the pattern create capturing groups. Reference them in the replacement string using $1 for the first group, $2 for the second, and so on. For example, the pattern (\d{4})-(\d{2})-(\d{2}) matches an ISO date. The replacement $3/$2/$1 rearranges it to day/month/year format. Named groups created with (?<name>...) can be referenced as $<name> in the replacement. The special sequence $& inserts the entire matched substring.
Global vs Single Replace
With the g flag enabled, every match in the text is replaced. Without g, only the first match is replaced and the rest of the text is left unchanged. For most find-and-replace tasks you will want the g flag on.
Match Extractor — Pull Every Match Out of Text Free
The Match Extractor runs the pattern against the input text and displays every match in a structured list in the right pane. Each result shows the match number, the matched text, and the character index where the match starts. If the pattern includes capturing groups, the value of each group is shown beneath the main match. This makes the extractor useful for pulling structured data out of unstructured text, such as extracting all email addresses, phone numbers, or dates from a document.
Exporting Extracted Data
The Copy button copies all matches as plain text with one match per line. The Download button saves the same text as a .txt file. For data pipelines or batch processing, this is a quick way to convert unstructured text into a line-separated list that can be imported into a spreadsheet, database, or script.
Understanding Capture Groups in Results
When the pattern includes parentheses, each match row in the extractor shows the group values labeled as $1, $2, and so on. For example, the pattern (\w+)@(\w+) on the text user@domain would show the full match user@domain with $1="user" and $2="domain" as the group breakdown. This is useful for validating that capturing groups are extracting the right portions of each match.
Regex to JavaScript Code Generator Online
The Regex to JS tool generates a complete, ready-to-use JavaScript code snippet from the pattern, flags, and test string you enter. The output includes the regex as both a literal and a RegExp constructor, followed by working examples using every major JavaScript regex method: .test(), .exec(), String.match(), String.matchAll(), String.replace(), and String.split(). Copy the snippet directly into your Node.js, Deno, or browser JavaScript project.
Literal vs Constructor Syntax in JavaScript
The regex literal /pattern/flags is the most common form. It is evaluated once when the JavaScript file is parsed, which means the pattern cannot be built dynamically. The new RegExp(pattern, flags) constructor accepts strings, making it the right choice when the pattern is assembled at runtime, for example from user input or a configuration value. Both forms are included in the generated code so you can choose whichever fits your use case.
When to Use matchAll in JavaScript
String.matchAll() requires the g flag and returns an iterator. Each item in the iterator is a full match array that includes the matched string, all captured groups, the index, and the input string. This gives you more information than String.match() with the g flag, which only returns an array of matched strings without group information. Use matchAll when you need group values for every match in a global search.
Regex Cheat Sheet and Quick Reference
The Cheat Sheet tab provides a reference for the most common regex syntax grouped into categories: anchors, character classes, quantifiers, groups, lookarounds, flags, and real-world patterns. Use it to look up a token without leaving the page and then switch back to the Regex Tester to try it immediately.
Anchors and Boundaries
The caret ^ and dollar sign $ match positions rather than characters. Without the m flag they match the very start and end of the entire string. With m enabled they match the start and end of each line. The word boundary \b matches the position between a word character and a non-word character, which is useful for matching whole words without accidentally matching them inside longer words.
Greedy vs Lazy Quantifiers
Greedy quantifiers like *, +, and {n,m} match as many characters as possible while still allowing the rest of the pattern to match. Lazy versions *?, +?, and {n,m}? match as few as possible. Lazy quantifiers are important when matching delimited content such as HTML tags or quoted strings where a greedy .* would consume too much.
Lookarounds Explained
Lookarounds are zero-width assertions. A positive lookahead (?=abc) succeeds only if the text ahead of the current position matches abc, but abc is not included in the match. A negative lookahead (?!abc) succeeds only if the text ahead does not match. Lookbehinds work the same way but check what precedes the current position. Both are fully supported in modern JavaScript.
How the Online Regex Tester Works
All five tools on this page use the JavaScript RegExp API built into your browser. When you enter a pattern and test text, the browser constructs a RegExp object and runs it against the text entirely in memory on your device. No content is transmitted to any server at any point. The tools work offline once the page has loaded and produce results instantly regardless of the length of the input text.
Because the JavaScript regex engine is used, the patterns follow JavaScript regex syntax. This means backreferences, named groups, lookaheads, and lookbehinds are all supported in modern browsers. The u flag can be toggled for Unicode-aware matching. Python-specific syntax such as (?P<name>...) is not supported, but the equivalent JavaScript named group syntax (?<name>...) is. For related developer tools on this site, see the JSON Formatter and HTML Editor.
Related Developer Tools
If you work with text processing and code regularly, these tools on the site pair well with the regex tester:
- JSON Formatter — format, validate, minify, and convert JSON in one tool
- HTML Viewer — live HTML preview, formatter, and tag stripper
- HTML Editor — full CodeMirror editor with live preview and validator
- Code Formatter — format HTML, CSS, JSON, XML, and JavaScript
- AI JavaScript Generator — generate JavaScript code with AI assistance
- AI Table Generator — generate formatted HTML tables with AI