Regex Tester
Test regular expressions with live match highlighting and capture groups.
How to use the regex tester
- Enter your regular expression pattern in the top field (without the surrounding slashes).
- Toggle flags as needed: i for case insensitive, m for multiline, s for dotall.
- Paste your test string in the text area below.
- Matches are highlighted in yellow instantly. The match list shows each match, its position, and any capture groups.
Common regex patterns
\d+— one or more digits[a-zA-Z]+— one or more letters\b\w+\b— whole words^.+$— entire non-empty line (with m flag)[\w.+-]+@[\w-]+\.[a-z]+— basic emailhttps?://[^\s]+— URLs\d+{3}-\d+{4}— phone pattern
JavaScript regex flavour
This tester uses JavaScript's built-in RegExp engine — the same one your browser and Node.js use. Patterns that work here will work in JavaScript code directly. Note that JavaScript does not support lookbehind in older browsers, named capture groups require ES2018+, and the s (dotall) flag requires ES2018+.
Who uses an online regex tester
Backend developers test form validation patterns for email addresses, phone numbers, and PIN codes before embedding them in server-side code. Frontend engineers prototype input sanitisation logic directly in the browser without switching to an IDE. Security researchers use it to analyse log patterns and extract IP addresses, user agents, or error codes from large log strings. Data engineers write regex patterns to parse semi-structured text from CSVs or API responses before loading into a database. Students learning regular expressions use it to experiment with patterns against real strings and immediately see how flags like i and m change behaviour.
Lookahead and lookbehind in JavaScript
JavaScript supports both positive and negative lookahead ((?=...) and (?!...)) and positive and negative lookbehind ((?<=...) and (?<!...)). Lookbehind requires ES2018 or later but is supported in all modern browsers. Example: (?<=₹)\d+ matches a number only when preceded by the ₹ symbol — useful for extracting amounts from financial text without capturing the currency symbol itself. Test lookaround patterns here to confirm they work as expected before using them in production.
Tips for debugging regex patterns
Start with the simplest possible pattern and build up incrementally. If a pattern is not matching, check for: unescaped special characters (a raw . matches any character — use \. for a literal dot); missing the m flag when anchoring to line boundaries with ^ and $; greedy vs lazy quantifiers swallowing more than expected. Use named capture groups ((?<year>\d{4})) to make complex patterns self-documenting.
Frequently asked questions
- What is a regular expression?
- A regular expression (regex) is a pattern that describes a set of strings. It's used to search, match, extract, validate, and replace text. For example, /\d+/ matches one or more digits, and /^[a-z]+$/i matches strings containing only letters.
- What flags are supported?
- This tester supports three flags: i (case insensitive — A matches a), m (multiline — ^ and $ match line boundaries, not just string boundaries), and s (dotall — . matches newlines too). The g (global) flag is always on so all matches are found.
- How do I match a literal dot or parenthesis?
- Escape it with a backslash: \. matches a literal dot, \( matches a literal opening parenthesis. In a regex pattern, characters like . * + ? [ ] { } ( ) ^ $ | \ have special meaning and must be escaped if you want them literally.
- How do capture groups work?
- Wrap part of your pattern in parentheses to create a capture group. For example, /(\d{4})-(\d{2})-(\d{2})/ matches a date and captures year, month, and day groups. The match list shows captured groups in the Groups column.
- What's the difference between greedy and lazy matching?
- Greedy quantifiers (*, +, ?) match . Lazy quantifiers (*?, +?, ??) match . For example, /<.+>/ on '<b>text</b>' matches the whole thing. /<.+?>/ matches '<b>' and '</b>' separately.
Related tools
- JSON Formatter, Validator & Repair Tool
Format, minify, validate, and repair JSON instantly in your browser. Sort keys alphabetically, auto-format on paste, download as file, escape/unescape strings — free, no sign-up, 100% client-side.
- QR Code Generator
Generate QR codes for URLs, text, Wi-Fi, and more. Download as PNG.
- Password Generator
Generate strong, random passwords with custom length and character sets.
- Base64 Encoder / Decoder
Encode text to Base64 or decode Base64 back to plain text.
- URL Encoder / Decoder
Encode or decode URLs and query strings with percent-encoding.