regex101
A free browser tool for writing, testing and debugging regular expressions. It highlights matches live against your test text, explains every token in plain English as you type, and includes a step-by-step debugger, a quick reference and a code generator. It suits anyone who copies patterns from the web without fully understanding them, or who needs to work out why a pattern fails or runs slowly.
Tool
Other
regex101
Minutes per use
All
Free
What the tool does
You pick a regex flavour, type a pattern and paste some test text. regex101 then:
- highlights every match and capture group as you type
- explains the pattern token by token in the side panel
- shows match details, including what each group captured
- supports substitution and list modes, not just matching
- generates code for the pattern in several languages
- lets you save a pattern with a shareable link, and browse a community library of saved patterns
Flavours matter because regex syntax differs between engines. The tool supports several, including PCRE2 (used by PHP), and others such as JavaScript, Python, Go, Java and .NET. Always choose the flavour your code actually runs on, or a pattern that works here can fail in production.
It is free to use without an account. Paid Pro and Enterprise tiers exist for extra features; check the site for what they include.
Features most people miss
- The debugger. It steps through how the engine attempts a match, backtrack by backtrack. This is the practical way to understand why a pattern is slow or why it matches more than you expected, and to spot catastrophic backtracking before it reaches a server.
- Unit tests. You can attach test strings that should and should not match, so later edits do not quietly break an earlier case.
- The benchmark and formatter, useful once a pattern grows long enough to be hard to read.
How to learn regex with it
- Open the quick reference and work through anchors, character classes, quantifiers and groups, testing each on a line of real data.
- Take a pattern you already use (an email check, a log line parser) and read the explanation panel for it. You will usually find a part you did not understand.
- Write the test cases first: five strings that should match and five that should not. Then build the pattern until all pass.
- Use the debugger on any pattern with nested quantifiers.
When regex is the wrong tool
regex101 makes it easy to keep adding to a pattern. If you are parsing HTML, JSON or anything nested, use a real parser instead. If a pattern needs a paragraph to explain, split it into steps in code. And never paste sensitive data such as customer records or keys into an online tool; use anonymised samples.
Common questions
Is it free? The core tool, including explanations, the debugger and saving patterns, can be used free in the browser. Pro and Enterprise tiers exist; check the site for what they add.
Can I use a pattern from here directly in my code? Yes, if you selected the right flavour. Use the code generator to get the correct escaping for your language, because backslashes are the usual source of bugs when copying across.
Is it safe for work data? Saved patterns can be shared by link, so treat anything you paste as potentially visible. Use made-up or anonymised test strings.
How long does it take to get comfortable with regex? A few focused hours on the quick reference covers most everyday needs. Lookarounds and backtracking behaviour take longer, and the debugger is the best way to learn them.
Best for: developers and students who write or maintain regular expressions and want to understand them rather than guess.
Ready to start?
Opens on regex101 in a new tab.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
Follow along
New writing, resources and project ideas land here first.