Regex tester
Type a regular expression and some text to see every match highlighted, with its capture groups, and try a replacement.
Your files stay on your device. Nothing is uploaded.
Step 1: Type the pattern
Step 2: Paste text to test
Step 3: Matches
| # | Match | Position | Groups |
|---|
After replacing
How to test a regular expression
-
Type the pattern
Type the pattern without the slashes, and tick the flags you need.
-
Paste test text
Matches are highlighted as you type, and listed with their position and groups.
-
Try a replacement
Type a replacement such as $2/$1 to see the text after replacing.
About this tool
JavaScript flavour
Patterns run with your browser's own regular expression engine, the same one used by JavaScript and TypeScript code, including named groups, lookbehind and Unicode.
Never freezes
Some patterns, such as (a+)+ on a long line, can take practically forever. Matching runs separately from the page and is stopped after 1.5 seconds, with an explanation, so the page never hangs.
Groups and replace
Each match lists its numbered groups ($1, $2) and named groups. The replace box uses the same $1, $<name> and $& codes as JavaScript.
Privacy
This tool runs in your browser, on your own device. Your files and text are not uploaded to our server and we cannot see them. When you close or reload this tab, they are cleared, along with the results.
Frequently asked questions
What do the flags mean?
g finds every match, i ignores capital letters, m makes ^ and $ work per line, s lets . match line breaks, and u turns on full Unicode.
Will my pattern work in PHP or Python?
Usually, for common patterns. Some features differ between languages, such as lookbehind and named group syntax.
Is my text uploaded?
No. It runs in your browser, so nothing you type or choose is sent anywhere.
Can I replace text in a document?
Yes, use Find and replace, which also supports regular expressions.
Related tools
- Replace Find and replace Replace words or patterns in text, with a count of changes.
- { JSON } JSON formatter Format, validate, minify and sort JSON.
- Diff Text compare Compare two texts and see what was added or removed.
- SQL SQL formatter Format and beautify SQL for MySQL, PostgreSQL and more.
- Dedupe Remove duplicate lines Delete repeated lines from a list, keeping the first copy.
- %20 URL encode and decode Percent-encode text for URLs, or decode it back.
- TS JSON to TypeScript Make TypeScript interfaces from a JSON sample.
- A › Z Sort lines Sort lines alphabetically, by number, by length or shuffle them.