Regex Tester
Guide: Regex Cheat Sheet for Beginners
Nothing you enter or choose here leaves your device. This tool runs in your browser.
How to use
- 1Type your regular expression and choose the flags you need.
- 2Paste or type the text you want to test against.
- 3See every match highlighted, with its position and capture groups.
- 4Tick "Test a replacement" to preview the result of a find and replace.
Frequently asked questions
Which regex flavor does this use?
JavaScript mode uses your browser's own regular expressions. Java, PHP and Python modes accept each language's syntax and translate it so the browser can run it. Most patterns give the same results, and anything that can't be reproduced is reported. Go, .NET and others aren't added yet.
How do PHP and Python patterns work here?
In PHP mode, type the pattern with its delimiters and modifiers, like /\d+/i. In Python mode, use the flag boxes and (?P<name>...) for named groups. Both can read patterns pasted from code, and both give you a ready-made snippet to copy.
How do I test a pattern I copied from Java code?
Switch to Java, paste the text from between the quotes, and tick "Pattern is a Java string literal" so the doubled backslashes (\\d) become real ones (\d). Then use Copy as Java to get a Pattern.compile snippet back.
What do the flags mean?
g finds all matches instead of the first, i ignores case, m makes ^ and $ match at each line, s lets the dot match line breaks, and u turns on full Unicode support.
Why does it say my pattern took too long?
Some patterns, such as nested repeats like (a+)+, can take exponentially long on certain text. The tester stops after two seconds so your browser never freezes. Make the pattern more specific to fix it.
Is my text sent anywhere?
No. Matching runs in your browser, in a background worker, and nothing is uploaded.
Read the guide
Learn how this works and how to get the most from it.
Developer
Regex Cheat Sheet for Beginners
A plain-English guide to regular expressions: character classes, quantifiers, groups, flags and examples you can test.
2 min read
Related tools
Text Diff Checker
Compare two texts side by side and see exactly what changed.
String Escape / Unescape
Escape and unescape strings for JSON, JavaScript, Java, Python, HTML, SQL, regex and CSV.
JSON Formatter & Validator
Prettify, minify and validate JSON, with error line numbers.
SQL Formatter
Format and beautify SQL for MySQL, PostgreSQL, SQL Server and more.