Test Regular Expressions
/…/g
Type a pattern and see every match highlighted in your text, with its position and capture groups. Add a replacement to preview a find and replace before you run it in code.
- Free
- Runs in your browser
- Live highlighting
- No sign-up
How It Works
Debug a pattern in three steps.
Write the pattern
Type it without the surrounding slashes and tick the flags you need.
Paste test text
Matches are highlighted and listed with their index and groups as you type.
Try a replacement
Optionally enter replacement text, with $1 or $<name> for groups, and copy the result.
Testing a regular expression
Regular expressions describe text patterns: \d{3} is three digits, ^ is the start of a line, (\w+)@ captures the part of an email before the @. They are compact and easy to get slightly wrong, so testing against real samples before putting a pattern into code saves debugging time. This tester uses your browser's JavaScript engine, so a pattern that works here works the same in JavaScript and TypeScript.
Regex flavors differ. Python, PHP (PCRE), Java and .NET support features JavaScript lacks, such as possessive quantifiers, and the other way round. Check the syntax for your language if you will run the pattern elsewhere.
Five flags
g (all matches), i (ignore case), m (^ and $ at each line), s (. matches newlines) and u (Unicode).
Capture groups
Each match lists its numbered groups, or named groups when the pattern uses (?<name>…).
Replacement preview
See the full text after replace(), using $1, $& or $<name> exactly as JavaScript does.
Clear errors
An invalid pattern, such as an unclosed bracket, shows the browser's error message.
Convert PDF Files and File Formats
Find the perfect online tool to combine PDF files, compress documents, and handle your daily workflow effortlessly.
PDF Tools
All your PDF needs in one place
- Merge PDF
- Organize PDF
- Split PDF
- Compress PDF
- Convert to Word
- Convert to Image
Image Tools
Edit and optimize your images
- Resize Image
- Compress Image
- Convert Format
- Crop Image
- Add Watermark
- Remove Background
Word Tools
Work with Word documents
- Convert to PDF
- Merge Documents
- Split Documents
- Compress File
- Edit Text
- Add Watermark
Excel Tools
Process Excel spreadsheets
- Convert to PDF
- Convert to CSV
- Merge Sheets
- Split Sheets
- Compress File
- Clean Data
Why Use This Regex Tester
See exactly what your pattern does.
Highlighted matches
Alternating colors make it easy to see where one match ends and the next begins.
Match table
Index, matched text and groups for each match, up to 1,000 counted and 200 listed.
Find and replace
Preview the result of a replacement on the whole text.
Private
Log files and data you test against stay in your browser.
Frequently Asked Questions
Questions people ask about the Regex Tester.
JavaScript (ECMAScript), as built into your browser. It supports lookahead, lookbehind, named groups and Unicode property escapes such as \p{L} with the u flag.
The g flag is off. Without it, JavaScript stops after the first match. It is on by default here.
No. Type the pattern without the surrounding /…/. Inside the pattern, escape special characters such as . * + ? ( ) [ ] { } | \ ^ $ with a backslash when you mean them literally.
Some patterns, such as (a+)+ on a long string, cause catastrophic backtracking, where the engine tries an enormous number of combinations. Make quantified groups more specific to avoid it.
Related Text & Developer Tools
More small utilities that run in your browser.
Find and Replace
Replace words or patterns in any text, with regex support.
SQL Formatter
Format and beautify SQL queries for 14 dialects.
Text Diff Checker
Compare two texts and see what changed, line by line.
JSON Formatter
Format, validate and minify JSON.
URL Parser
Split a URL into its parts and query parameters.