Developer Tools

Regex Tester

Test and debug regular expressions with live matches, groups, and index positions.

Hello World
Match 1 at 0Hello
Match 2 at 6World
Quick referenceEmail: [\\w.-]+@[\\w.-]+URL: https?:\\/\\/\\S+Phone: \\+?[0-9 -]{7,}Date: \\d{4}-\\d{2}-\\d{2}

About the regex tester

Type a pattern and a test string, and every match is highlighted as you type. Below the text is a numbered list of matches with the position where each one starts, counted from 0, and the value of every capture group. The g, i, m, s and u flags are checkboxes, and Share copies a link that opens the tester with your pattern, text and flags. Patterns run on your browser's own JavaScript engine, so what matches here matches in JavaScript and TypeScript code. Named groups like (?<year>\d{4}) and lookbehind work in current browsers, although lookbehind needs Safari 16.4 or later, released in March 2023. The g flag is always applied behind the scenes, so the list shows every match even with its box unticked. The quick reference holds four starter patterns for email addresses, URLs, phone numbers and dates written as year, month and day. They are deliberately loose: good for pulling likely matches out of text, not for strict validation. Everything runs in your browser, but a Share link puts your pattern and text into the URL, so don't share one that contains private data.

Frequently asked questions

Which regex flavor is this?

JavaScript (ECMAScript), as built into your browser. Everyday syntax works much the same in Python, Java, PHP and .NET, but details differ. Python's re module, for example, writes named groups as (?P<name>...), where JavaScript uses (?<name>...). Test in your target language when a pattern leans on less common features.

What do the g, i, m flags do?

g finds every match instead of stopping at the first; this tester always applies it for the list. i ignores the difference between capital and small letters. m makes ^ and $ match at the start and end of each line instead of the whole text. The other two: s lets the dot match line breaks, and u switches on full Unicode mode, needed for escapes like \p{L} and for treating an emoji as one character.

Why does my pattern show zero-length matches?

A pattern that can match nothing, such as a* or \d*, matches the empty string at every position where a real match fails, so the list fills with empty entries. Use + instead of * when you need at least one character.

How do I see what a capture group caught?

Each match in the list shows its groups underneath as Group 1, Group 2 and so on, numbered by the order of their opening parentheses. A group that didn't take part in the match shows not matched. Named groups are numbered too, so (?<year>\d{4}) appears as Group 1 when it is the first group.