Regex Tester
Regex Tester (JavaScript Regular Expressions)
Enter a pattern and some text to see every match highlighted as you type. The match list shows positions and capture groups, and you can preview a replacement. Pick a common pattern to get started. Everything runs in your browser.
Matches
Match list
| # | Position | Match | Groups |
|---|
Result
Quick reference
.- Any character (except line breaks without the s flag)
\d \w \s- Digit / letter, digit or _ / whitespace (\D \W \S are the opposites)
^ $- Start / end of the text (of each line with the m flag)
* + ? {2,4}- 0 or more / 1 or more / 0 or 1 / 2 to 4 times (add ? for the shortest match)
[abc] [^abc] [a-z]- One of / none of / range
(…) (?:…) (?<name>…)- Capture group / non-capturing group / named group
a|b- a or b
(?=…) (?!…) (?<=…) (?<!…)- Followed by / not followed by / preceded by / not preceded by
\b- Word boundary
\p{Script=Han}- Characters of a script (needs the u flag)
- This tool uses the JavaScript (ECMAScript) regular expression engine of your browser. Results may differ slightly in PHP, Python, Ruby and other languages.
- In the replacement, $1 to $99 insert groups, $<name> a named group, $& the whole match, and $$ a literal $.
- To keep the page responsive, matching stops after about 2 seconds, the test string is limited to 200,000 characters, and up to 10,000 matches are counted.
About this tool
Test JavaScript regular expressions instantly. Matches in your test string are highlighted, with a list of positions, groups and named groups, and a live replacement preview. Start from common patterns such as email addresses, URLs, dates and Japanese postal codes, and use the quick reference while you work. Everything runs in your browser, and heavy patterns are stopped after about 2 seconds so the page does not freeze.
How to use
- Enter a regular expression in Pattern and choose the Flags (g, i, m, s, u, y), or pick one from Common patterns.
- Type or paste text into Test string. Matches are highlighted and counted.
- Check the positions and group values in the Match list.
- Enter a replacement using $1 or $<name> in Replace with to see the Result, then Copy it.
Useful for
- Writing regular expressions for form validation
- Checking a pattern before a bulk find-and-replace in your editor
- Extracting specific parts from logs or data
- Learning regex syntax by trying it out
FAQ
What is a regular expression?
A way to describe a pattern of characters, such as four digits or text containing @, using symbols. It is used for searching, replacing and validating input.
Can I test PHP or Python regex here?
The tool uses your browser's JavaScript regular expressions. The basics are the same, but some syntax and results differ between languages.
Why is only one match shown?
Without the g flag, only the first match is found. Tick g to find all matches.
Is my text sent anywhere?
No. Matching happens entirely in your browser.
Updates to this tool
All updatesReleased 19 new tools, including find and replace, date and business-day calculators, a tsubo/m² converter, image cropping, transparent PNGs, .htaccess redirects, robots.txt and a timer, for 44 tools in total
Other free tools
All 183 free tools- JSON Formatter and ValidatorFormat or minify JSON and find syntax errors with their position.
- Encoder and DecoderConvert URL encoding, Base64, HTML entities and Unicode escapes both ways.
- Hash and UUID GeneratorCalculate MD5 and SHA hashes of text or files, verify checksums and generate UUID v4 in bulk.
- Unix Timestamp ConverterConvert Unix timestamps (seconds or milliseconds) to and from dates in Japan time, UTC and ISO 8601.
- CSV to JSON / JSON to CSV ConverterConvert CSV to JSON and JSON to CSV with quoted values, table preview and Excel-ready download.
- Color Code Converter (HEX, RGB, HSL, CMYK)Convert colors between HEX, RGB, HSL, HSV and CMYK, find the nearest color name and copy CSS.
- Markdown Preview and Markdown to HTML ConverterWrite Markdown with a live preview and copy the converted HTML. Tables and task lists supported.
- JWT DecoderDecode a JWT to view its header and payload, with exp and iat converted to dates.