Test a regular expression before it reaches your code
This regex tester runs your pattern against sample text and highlights every match, so you can see at once whether a regular expression does what you meant. Each match is listed with its position and its capture groups.
Debug regex with groups and a replace preview
Named groups, flags and a replacement string are supported, which makes it easy to test regex online and check the final text before it goes into your code. The tool uses the JavaScript engine in your browser, so the behaviour matches what you get in a web page or in Node. Other languages differ in small ways, for example in how they treat lookbehind or named groups, so test again in your own environment before you rely on a pattern.
How to use Regex Tester
- Type the pattern without slashes, for example (\d+)-(\w+).
- Tick the flags you need, such as g, i or m.
- Paste the test text, solve the security check and press Test.
- Read the highlighted text and the match table, then try a replacement.
About Regex Tester
The tool builds a RegExp object with your pattern and flags and loops over the matches. Empty matches move the search forward by one character so the loop always ends, and at most 1000 matches are shown. The replace preview uses String.replace, so $1, $& and $<name> work as in JavaScript.
Purpose of Regex Tester Tool
Use it to build a validation pattern, pull values out of logs, check a search-and-replace before running it on a file, or learn how groups, lazy quantifiers and lookaheads behave.
Limitations of Regex Tester
- It uses the JavaScript engine. PCRE, Python or .NET features such as possessive quantifiers or inline modes may not work.
- A pattern with heavy backtracking can freeze the page. Keep test text short while you tune such a pattern.
- Only the first 1000 matches are shown, and text over 200000 characters is refused.
- Lookbehind and the s, u, v and d flags depend on your browser version.
Privacy and data
Regex Tester runs entirely in your browser. What you type or select is processed on your own device and is never sent to or stored on our server. See our Privacy Policy for details.
Frequently asked questions
Why does my regex match nothing?
Check the flags first. Without i, matching is case sensitive, and without m, ^ and $ only match the start and end of the whole text. Also remember to escape characters such as . ( ) and ?.
What does the g flag do?
The g flag finds all matches. Without it, only the first match is returned.
Is the regex tester free and safe to use?
Yes. The regex tester is free to use and runs in your browser, so your pattern and text is not uploaded, stored or logged.
How do I test a regular expression online?
Type your pattern, choose the flags and paste your test text. Every match is highlighted and the capture groups are listed.
Which regex flavour does the tester use?
It uses JavaScript regular expressions. Basic patterns work the same in most languages, but some features, such as lookbehind and named groups, differ between engines.
Rate Regex Tester
No ratings yet. Be the first to rate this tool.
Report a bug or give feedback
Popular tools
Morse Code to Text
Decode Morse code made of dots and dashes into readable text, with flexible separators and error marking.
Text ToolsWebpage URL to Text
Turn a web page address, pasted page source or an HTML file into clean readable text without ads and menus.
Text ToolsASCII to Text Converter
Decode decimal, hex or octal ASCII codes into text, with auto-detection, a code table, control-character names and clear errors for bad codes.
Text ToolsBinary to Text Converter
Decode binary into text as UTF-8, 7-bit ASCII or 16-bit UTF-16, with or without spaces, and find exactly what is wrong when it will not decode.
Text ToolsBMI Calculator
Work out your BMI, category and healthy weight range in metric or imperial units.
Health ToolsBullet List Generator
Turn lines, commas or sentences into a bullet, numbered or checklist, with nested levels, as text, Markdown or HTML.
Text Tools