Regex Tester
Test a regular expression against your own text and see every match highlighted, along with numbered and named capture groups. Patterns run with your browser’s JavaScript RegExp engine, and your text stays on your device.
Type the pattern without the surrounding slashes. Press Enter to test.
Press Ctrl+Enter (⌘+Enter on Mac) to test from here.
Patterns run with your browser’s JavaScript RegExp engine, so syntax and behaviour can differ slightly from PCRE, Python or other languages. Your pattern and text stay on this device.
How to Use the Regex Tester
- Type your pattern into the Regular expression box, without the surrounding slashes.
- Tick the flags you need. g finds every match instead of only the first, i ignores case and m makes ^ and $ match at the start and end of each line.
- Paste the text you want to search into Test text.
- Press Test regex, or Enter in the pattern box, to see the match count, highlighted matches and capture groups.
- Not sure where to start? Choose an example pattern and press Load example.
Examples
Find dates with named groups
- Input
- Pattern: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) Flags: g Text: Released 2024-03-15, patched 2024-04-02.
- Output
- 2 matches Match 1: 2024-03-15 (year 2024, month 03, day 15) Match 2: 2024-04-02 (year 2024, month 04, day 02)
Whole-word search, ignoring case
- Input
- Pattern: \bcat\b Flags: gi Text: Cat, cats and CAT.
- Output
- 2 matches Match 1: Cat (index 0) Match 2: CAT (index 14)
About the Regex Tester
Regular expressions are a compact language for describing patterns in text. Developers use them to validate input such as email addresses and postcodes, search logs, extract values and power find-and-replace in editors. A tester lets you try a pattern on real examples before you put it into code.
This tester uses the JavaScript RegExp engine built into your browser, so results match what new RegExp() does in JavaScript and TypeScript. Most syntax is shared with other languages, but not all of it: JavaScript has no possessive quantifiers or atomic groups, for example, and some Unicode features differ between engines. Check your language’s documentation if the pattern is for Python, PHP, Java or .NET.
Your pattern is only ever passed to the RegExp constructor; it is never run as code. Matching happens in a background worker, so if a pattern takes too long, usually because of catastrophic backtracking from nested quantifiers like (a+)+, it is stopped after a few seconds instead of freezing the page. Up to 1,000 matches are shown.
Your pattern and test text are processed in your browser and are not sent to a Usevanta server, so it is fine to test against log lines or sample data.
Frequently Asked Questions
Which regex flavor does this tester use?
JavaScript (ECMAScript), using the RegExp engine in your browser. Results match JavaScript and TypeScript code running in the same browser. Patterns written for PCRE, Python or .NET usually work, but some features differ.
Why does my pattern only find one match?
Without the g (global) flag, JavaScript stops after the first match. Tick g to find every match in the text.
What are capture groups?
Parts of a pattern wrapped in parentheses. Each group captures the text it matched, numbered from 1 in the order the groups open. Named groups such as (?<year>\d{4}) are listed by name as well. Use (?:...) to group without capturing.
Why is my regex invalid?
Common causes are unbalanced parentheses or brackets, a quantifier with nothing to repeat (such as * at the very start), or an escape that is not allowed in Unicode mode. The error message comes from your browser and usually names the problem.
Do I need to escape forward slashes?
No. You type the pattern without the surrounding slashes, so / can be used as is. You only need \/ when writing a regex literal like /a\/b/ directly in JavaScript code.
Related Tools
All developer tools →Pull URLs, email addresses, hashtags, @mentions and numbers out of any text.
Format and validate JSON directly in your browser.
Sort lines of text alphabetically or by length, with options to remove blanks and duplicates.
Collapse repeated spaces, trim lines and tidy up blank lines in any text.