Input checks
Check whether a value follows an expected shape, such as a product code, username, date string, or slug. Test valid examples and near-misses so the pattern does not accept more than you intended.
JavaScript Regex Tester & Debugger
Write it. Test it. Understand it.
Test JavaScript regular expressions with live match highlighting, capture group details, flags, and a replace preview. Your patterns and test text are processed in your browser.
Enter a pattern, choose the flags, and add a sample string. Matches appear below as you type. Use the quick patterns for common starting points or consult the reference guide when you need a reminder.
Replacement preview
Quick patterns
Syntax at a glance
Common tokens, quantifiers, groups, anchors, and flags.
A practical guide for developers
Regexx is a free online JavaScript regex tester for writing, checking, and refining regular expressions. Enter a pattern and a test string to see matching text highlighted, inspect match positions and capture groups, and preview a replacement without changing the original input.
Regular expressions describe text patterns. They are useful when a task is easier to express as a rule than as a sequence of manual string operations: finding identifiers in logs, checking the shape of form input, extracting values, locating repeated whitespace, or transforming text in an editor. Regexx gives you a focused place to test those rules against real examples before using them in an application.
Input checks
Check whether a value follows an expected shape, such as a product code, username, date string, or slug. Test valid examples and near-misses so the pattern does not accept more than you intended.
Text extraction
Find repeated identifiers, timestamps, tags, key-value pairs, or structured fragments in logs and documents. Capture groups let you isolate the parts you need from each match.
Search and cleanup
Locate multiple spaces, inconsistent separators, unwanted prefixes, or repeated text. A replacement expression can normalize those fragments while preserving selected parts through backreferences.
Developer workflows
Prototype patterns for JavaScript code, editors, data preparation, test fixtures, and log inspection. Confirm how a pattern behaves on multiline input and edge cases before adding it to a project.
These examples are starting points, not universal validation rules. Load one into the tester, add realistic sample data, and adjust it to match the exact format your application expects.
^-?\d+$
Matches an optional minus sign followed by one or more digits, with no extra characters before or after.
^\d{4}-\d{2}-\d{2}$
Checks the YYYY-MM-DD shape. It does not prove that the day exists in the specified month; validate calendar values separately.
\s+
Finds one or more whitespace characters, useful when normalizing repeated spaces, tabs, or line breaks.
^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.+)$
Captures a simple identifier and its non-empty value. Enable m to apply the anchors to each line of a multiline string.
^[a-z0-9]+(?:-[a-z0-9]+)*$
Matches lowercase letters and digits separated by single hyphens, without leading or trailing separators.
^[^\s@]+@[^\s@]+\.[^\s@]+$
Checks a common email-like structure. It is not a complete implementation of every valid email address format.
A good pattern starts with examples, not with the most compact expression possible. Build it in small steps and test both the values you expect to match and values that should be rejected.
^ and $ when the whole value must match.i for case-insensitive matching, m for line-based anchors, s when a dot should include line breaks, and g to find every occurrence.$1, $2, or named backreferences produce the intended output.^ and $ match positions at the beginning and end of the input. With the m flag, they also match at line boundaries. Anchors do not consume characters; they constrain where a match can begin or end.
*, +, and ? describe how many times a token may appear. By default, quantifiers are greedy. Adding ? after a quantifier makes it lazy, so it takes the shortest match that satisfies the rest of the pattern.
(...) creates a numbered capture group. (?:...) groups part of a pattern without capturing it. Named groups such as (?<code>...) make extracted values easier to identify.
Lookahead and lookbehind assertions check what appears before or after a position without including that context in the matched text. They are useful when a value must be adjacent to a delimiter or another token.
Regexx uses the JavaScript RegExp engine supplied by the browser. This makes it useful for testing patterns intended for frontend JavaScript and other environments that follow JavaScript regular-expression syntax. Modern browsers support named capture groups, lookahead, lookbehind, Unicode-aware matching, and additional regular-expression features, but exact support can depend on the browser version.
Regular-expression flavors are not interchangeable. A pattern copied from a PCRE, Python, .NET, Java, or Ruby example may use syntax that JavaScript does not recognize or interpret differently. For example, PCRE-specific constructs such as \K and conditional patterns are not part of JavaScript RegExp. Always test a pattern in the same flavor that will run in production.
Regular expressions work best for recognizable text patterns and local transformations. They are not a substitute for a parser. Use a JSON parser to read nested JSON, an HTML parser to inspect document structure, and a programming-language parser when syntax and nesting matter. A regex can help find a simple fragment inside those formats, but it cannot reliably interpret every nested or escaped structure.
Also be careful with patterns that combine nested or overlapping repetition. Some backtracking expressions can explore a very large number of alternatives when the input almost matches but ultimately fails. This can make a match unexpectedly slow. Keep patterns specific, avoid unnecessary nested quantifiers, and test long or adversarial examples when input may come from untrusted users.
Regexx performs pattern matching and replacement in your browser. Matching runs in a dedicated Web Worker so the main interface can remain responsive while the test string is processed. The pattern and sample text are not sent to a Regexx processing backend, and the original test string remains unchanged when you preview a replacement.
A Web Worker improves interface responsiveness; it does not make every pattern fast or remove the CPU and memory limits of the device. A poorly constructed expression can still consume significant local processing time. Use the tester to examine behavior carefully before relying on a complex pattern in a production workflow.
Answers to common questions
The answers below are shown directly on the page, so you can scan the details without opening or expanding hidden panels.
Yes. Regexx is a free online JavaScript regex tester. You can test patterns, inspect matches, use capture groups, and preview replacements without creating an account.
Regexx uses the JavaScript RegExp engine available in your browser. It supports JavaScript regular expression syntax, including named capture groups, lookahead, lookbehind in modern browsers, and the g, i, m, and s flags exposed by the interface. PCRE-only syntax such as \K and conditional patterns is not supported.
Regex matching and replacement are performed in your browser. The pattern and test string are passed to a local Web Worker for processing and are not uploaded to a Regexx processing server.
The g flag finds all matches, i ignores letter case, m changes the behavior of the ^ and $ anchors so they work at line boundaries, and s makes the dot character match line terminators as well.
Use parentheses in the pattern to create capturing groups. In the replacement field, refer to numbered groups with $1, $2, and so on, or named groups with $<name>. Regexx displays a preview and leaves the original test string unchanged.
A practical regex can check the common shape of an email address, but complete email validation involves rules and edge cases that are better handled with a dedicated validation process and, ultimately, confirmation that the address can receive mail.
Regex is useful for locating simple text patterns inside markup or JSON strings, but it is not a reliable parser for nested structures. Use an HTML or JSON parser when you need to understand document structure, nesting, or escaped values.
Check whether the pattern is anchored, whether case or multiline behavior requires a flag, whether whitespace or line endings differ from the example, and whether the pattern expects a different format. A valid pattern can correctly return zero matches when the test string does not satisfy it.
Some patterns create many alternative paths for a backtracking regex engine, especially when nested or overlapping quantifiers are used. This can cause excessive processing time on certain inputs. A Web Worker keeps matching away from the main interface thread, but it does not make an inefficient pattern computationally cheap.
Regexx does not currently create shareable pattern links. Copy the pattern and its flags into a message, code review, or documentation so the recipient can reproduce the test.