Developer Tools

Free Regex Tester Online — Real-Time Matching, Groups & Explainer

Test, debug and understand regular expressions instantly. Real-time match highlighting, named group extraction, replace mode, 20+ pattern library and a plain-English regex explainer.

//gi
Flags:
2Matches
48Pattern length
100Test string length
0Groups
Contact us at hello@purstech.com or support@example.org for help. Invalid: not-an-email @missing.com
#MatchIndex
1hello@purstech.com14
2support@example.org36

How to Use the Regex Tester

1
Enter your pattern
Type a regex pattern in the input field. Red border + error message appears immediately if the syntax is invalid. Toggle flags (g, i, m, s) as needed.
2
Paste your test string
Enter the text you want to match against in the test string area. Matching highlights appear in real time as you type.
3
Use Match, Replace or Explain
Match mode shows highlighted results and a groups table. Replace mode shows the text after substitution using $1 or named group references. Explain breaks down every token.
4
Load a pattern from the library
Open the Pattern Library to find ready-to-use regex patterns for emails, URLs, dates, phone numbers, hex colours, HTML tags and more.

❓ Frequently Asked Questions

What is a regular expression (regex)?+
A regular expression is a sequence of characters that defines a search pattern. Used in programming for string searching, validation and manipulation, regex is supported natively in JavaScript, Python, Java, PHP and most modern languages. For example, the pattern /^[\w.]+@[\w]+\.[a-z]{2,}$/i matches most email addresses. Mastering regex allows you to solve complex text-processing tasks in a single line of code.
What do the regex flags g, i, m, s mean?+
The g (global) flag finds all matches instead of stopping at the first. The i (case-insensitive) flag makes the match ignore letter case. The m (multiline) flag makes ^ and $ match the start and end of each line rather than the whole string. The s (dotAll) flag makes the dot (.) match newline characters as well as other characters — without this flag, . doesn't match \n. You can combine flags: /pattern/gim applies global, case-insensitive and multiline simultaneously.
What is the difference between greedy and lazy matching?+
Greedy quantifiers (*, +, ?) match as much text as possible while still allowing the overall pattern to match. Lazy quantifiers (*?, +?, ??) match as little text as possible. For example, on the string '<a>text</a>', the greedy pattern <.*> matches the entire string '<a>text</a>', while the lazy pattern <.*?> matches only '<a>'. Use lazy matching when you want to match the shortest possible string between delimiters.
How do named capture groups work?+
Named capture groups use the syntax (?<name>pattern) and allow you to reference matched text by a meaningful name instead of a number. For example, /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/ on '2025-01-15' creates groups year='2025', month='01', day='15'. In JavaScript you access them via match.groups.year. Named groups make complex regex patterns far more readable and maintainable, especially when you have many capture groups.
What are lookahead and lookbehind assertions?+
Lookahead (?=...) asserts that what follows the current position matches the pattern without consuming characters. Negative lookahead (?!...) asserts it does NOT match. Lookbehind (?<=...) asserts that what precedes the current position matches. For example, /\d+(?= dollars)/ matches a number only if followed by ' dollars', and /(?<=\$)\d+/ matches digits only if preceded by '$'. Lookarounds are powerful for context-dependent matching without including the context in the result.