Text
Regex Tester / Find & Replace
Test regular expressions against real text: highlighted matches with parsed capture groups, or replace matches with new text.
A regular expression (regex) is a compact language for describing patterns in text — for searching, validating a format, or replacing matches. This tool highlights matches in real text as you type the pattern, breaks out capture groups, and supports a find-and-replace mode.
How to use it
- Search: enter a pattern and some test text — every match is highlighted and capture groups are broken out separately.
- Replace: switch to Replace mode, provide a replacement template (referencing groups with $1, $2), and see the result instantly.
- Flags (g, i, m, s) toggle independently and immediately affect how many matches are found and how.
Common uses
- Building and debugging a regex before pasting it into code — you see the result without running the program.
- Bulk find-and-replace against a pattern (e.g. reformatting phone numbers or dates).
- Validating an input format (email, card number, slug) against real examples.
Things to keep in mind
Greedy quantifiers (*, +) grab as many characters as possible — add ? for the minimal match instead (e.g. .*? instead of .*).
Syntax varies slightly between languages — an expression that works here (a JavaScript engine) may need adjusting for PCRE, .NET, or Python.
Article about this tool: Regular expressions: basic syntax and common patterns
Frequently asked questions
Which regex engine is used?
The tool uses JavaScript's regex engine, not PCRE, so some PCRE-specific syntax (like recursive assertions or certain possessive matching modes) won't work here; common flags like g, i, m, s, and u are supported.
What's the difference between greedy and lazy quantifiers, and between Test and Replace?
A greedy quantifier like * or + captures as much text as possible, while its lazy version (*?, +?) stops as early as possible; as for modes, Test highlights matches and lists capture groups (including named ones), and Replace applies replacement text, with references like $1, to each match.
Are my text and expression sent to a server?
No, regular expression evaluation happens entirely client-side in your browser, nothing is transmitted online.
What is catastrophic backtracking?
Nested quantifiers like (a+)+ can, on certain inputs, force the engine to try an exponential number of combinations — the page or script "freezes" on what looks like a simple expression. This is a real vulnerability class (ReDoS), so complex nested quantifiers should be stress-tested against long near-match strings.
Why does my expression work in one programming language but not another?
Regex syntax isn't fully standardized: PCRE (PHP and many other languages), .NET, Python's re, and JavaScript have subtle differences in support for certain constructs (like look-behind or named groups) — an expression written for one engine doesn't always work unchanged in another.