Regex Tester
regex-test• Enter a pattern and flags to highlight matches in real time. • Inspect capture groups, preview replacements, and use common pattern presets.
All matching runs in your browser. Without the global (g) flag only the first match is captured. Replacement supports $1·$2 (groups), named groups, and $& (whole match).
When a regex tester helps
A regular expression is a notation for finding patterns in text. It is used for validating an email format, pulling one value out of a log line, or doing a rule-based find and replace.
The trouble is that you cannot tell whether a pattern is right just by looking at it, and editing it inside your code means a slow run-and-retry loop. Paste the pattern and the target text here and the matches are highlighted immediately, so you can adjust and check as you go.
Try the flags as well: g finds every match, i ignores case and m handles multiple lines. Patterns here follow JavaScript syntax, so a few constructs differ in other languages. Your input is processed only in your browser.
Frequently asked questions
Which flavour of regex does this use?
It runs on the browser JavaScript regex engine, so a pattern that works here drops straight into JavaScript or TypeScript. Python, Java and grep differ on things like lookbehind and named group syntax, so check the target language when you port a pattern over.
What do the g, i and m flags mean?
g finds every match instead of stopping at the first, and i ignores case. m makes the start and end anchors apply to each line rather than the whole string. There are also s, which lets a dot match line breaks, and u, for correct handling of unicode characters.
How do I capture just one part of the match?
Anything wrapped in parentheses is listed separately as group 1, group 2 and so on for each match. That is how you pull the year, month and day out of a date, or one value out of a log line. With replace turned on you can reference those groups by dollar sign and number, and named groups are listed too.
My pattern matches far more than I wanted
Star and plus are greedy by default, so an attempt to grab one tag swallows everything from the first tag to the last. Add a question mark after the quantifier to take the shortest match, or use a character class that excludes the closing character to fence the range in.
Are there ready-made email, phone and number patterns?
There is a row of common patterns that fills in email, mobile number, link, number, Hangul, date and tag with one click. The phone pattern matches with or without hyphens, and the email one is a practical simplified form you can edit right here to fit your case.
Only one match is showing up
With the g flag off, a regex stops at the first match. Turn g on to find them all. The same applies to replace: without g only the first occurrence changes, so check that g is enabled when you want a bulk replacement.