Regex Tools

Test, build and understand regular expressions in your browser, with live match highlighting, plain-English explanations, find and replace, data extraction, ReDoS checks and ready-to-paste code. Learn more

Quick

Common Pattern Library

Ready-made patterns for email, phone, URL and more.

Quick

Email/URL/Phone Extractor

Pull contacts out of any text.

Standard

Log Line Filter

Grep-style filtering by string or regex.

Standard

Log Pattern Builder

One example line → a matching regex.

Standard

Named Capture Group Extractor

Text + regex → structured fields.

Standard

Plain-English Regex Explainer

A part-by-part explanation of any pattern.

Standard

ReDoS/Backtracking Checker

Finds risky backtracking shapes and times them.

Quick

Regex Cheat Sheet

Quick reference for common syntax.

Quick

Regex Code Generator

Ready-to-paste code for JS, Python, PHP and Java.

Standard

Regex Find & Replace

Replace text with full regex and capture groups.

Standard

Regex Flags Playground

See exactly what g, i, m, s, u and y do to your regex, live

Advanced

Regex Golf

Practice puzzles: match these, not those.

Standard

Regex Lookaround Playground

Learn lookahead and lookbehind with live highlighting

Standard

Regex Match Table Exporter

Export regex matches as a CSV table

Advanced

Regex Railroad Diagram

Visualise a pattern as a left-to-right diagram.

Standard

Regex Tester

Live match highlighting against your own text.

Standard

Regex Unit Test Runner

Test a regex against a whole list of cases

Standard

Visual Regex Builder

Click building blocks to construct a pattern.

Regular expression tools for writing, testing and understanding patterns

Regular expressions are one of the most useful skills in programming, and one of the easiest to get wrong. The Regex Tester highlights every match in your own text as you type, and Regex Find & Replace rewrites text using capture groups, so $2 $1 turns "John Smith" into "Smith John". If you're new to regex, the Visual Regex Builder lets you click building blocks together, the Regex Cheat Sheet has the syntax you forget most often, and Regex Golf turns practice into a set of quick puzzles.

Inherited a pattern you can't read? The Plain-English Regex Explainer breaks it down part by part, with the contents of each group indented beneath it. The Regex Railroad Diagram draws the same pattern as a left-to-right picture. To learn the trickier features properly, the Flags Playground shows what g, i, m, s, u and y change, and the Lookaround Playground makes lookahead and lookbehind make sense.

For real work on real data, the Named Capture Group Extractor turns log lines into a table of fields, and the Match Table Exporter exports every match as CSV for a spreadsheet. The Log Pattern Builder writes a pattern from a single example line, the Log Line Filter works like grep in the browser, and the Email/URL/Phone Extractor pulls contact details out of any text. Before a pattern goes into production, check it with the Unit Test Runner, look for slow backtracking with the ReDoS Checker, and then paste the result into your code with the Regex Code Generator for JavaScript, Python, PHP or Java.

Questions and answers

What's the difference between the Regex Tester and the Regex Unit Test Runner?
The Regex Tester is for exploring: paste some text and watch every match light up as you edit the pattern. The Unit Test Runner is for checking a finished pattern. You list inputs with the result you expect for each (555-1234 => true, 55-1234 => false) and it tells you which pass. Keep that list as you tweak the pattern, and you'll see straight away if a change breaks a case that used to work.
Should I use the Plain-English Explainer or the Railroad Diagram to understand a pattern?
Use both for a tricky one. The Explainer is the more precise of the two. It describes every token, including lazy quantifiers, backreferences and lookarounds, and indents the contents of each group so you can see exactly what a quantifier repeats. The Railroad Diagram gives the overall shape at a glance, one box per step from left to right, with an arc over anything that repeats. It's quicker for getting the gist of a long pattern.
Which tool should I use to pull data out of text: the Named Capture Group Extractor or the Match Table Exporter?
Use the Named Capture Group Extractor when you want to read the results on screen: name your groups, as in (?<date>…), and each match becomes a row in a labelled table. Use the Match Table Exporter when the data is going into a spreadsheet. It outputs CSV with the full match, its position and every numbered and named group, quoted properly so commas and line breaks don't break the columns.
What is ReDoS, and how do I know if my pattern is at risk?
ReDoS (regular expression denial of service) happens when a pattern like (\w+\s?)*$ meets input that almost matches but then fails. The engine tries every possible way of splitting the text, and the time can double with each extra character. The ReDoS Checker spots the three shapes that usually cause it. Its timing test then runs your pattern against input built to trigger them, in the background, and stops it after 3 seconds if it runs away. If a pattern is flagged, rewrite it so the repeats can't overlap, or limit the length of the input it receives.
Will a pattern I build here work in Python, PHP or Java?
Usually, but not always word for word. Every tool here uses your browser's JavaScript regex engine, and other languages differ in a few places. Python writes named groups as (?P<name>…), Python and PHP only accept fixed-length lookbehind, and none of them use the g flag. The Regex Code Generator handles the common differences for you: it escapes the string for each language, converts the flags, rewrites named groups for Python and adds a note when something won't carry across.