Regex Tester
Test Regular Expressions in real-time.
//
About regular expressions
A regular expression (regex or regexp) is a compact pattern language for matching text. Regex powers find-and-replace in editors, route matching in web frameworks, log filters, input validation, and lexical analysis in compilers. It is also famously hard to debug — which is why nearly every developer has a regex tester in their bookmarks.
This tester runs your regex against any sample text in real time, highlights every match, explains the named capture groups, and supports JavaScript flags (g, i, m, s, u, y). Because everything happens in your browser using the native RegExp engine, you can paste production log lines without worrying about leakage.
Do not parse HTML or JSON with regex
HTML and JSON are not regular languages — they have nested, recursive structure that regex cannot represent. Patterns that look like they work will break on the first edge case (an attribute containing <, an escaped quote inside a string). Use a real DOM parser for HTML, and our JSON formatter or JSON.parse for JSON.How to use
- Paste your regex pattern into the pattern field. Add flags such as g (global), i (case-insensitive) or m (multiline).
- Paste the test text into the input area.
- Each match is highlighted live. Capture groups are listed below with their indexes and names.
- Use the replace field to preview a substitution against the same input.
Common use cases
- Building input validators for forms (email, phone, postcode).
- Extracting fields from log lines for monitoring and alerting.
- Search-and-replace in large codebases.
- Routing requests in web frameworks.
Frequently asked questions
Which regex flavour does this support?
JavaScript-compatible regex via the browser's native RegExp object. Most patterns also work in PCRE, Python, and Go with minor syntactic differences.
Why is my regex matching too much?
Quantifiers like * and + are greedy by default. Append a ? to make them lazy: .+? matches as little as possible.
Can a regex parse HTML?
For trivial extraction yes; for general parsing, no. HTML is not a regular language. Use a real DOM parser when correctness matters.
What is the difference between (?:...) and (...)?
(...) is a capturing group whose match is exposed in the results. (?:...) is a non-capturing group used purely for grouping operators.
Advertisement