Regex Tester

Test regex patterns with live match highlighting. Generate code for JavaScript, Python, and PHP.

Last updated: April 2026
Pattern
gims
//gi
Test String
Matches
Code Generator
Select a language above

What are Regular Expressions?

Regular expressions (regex) are patterns that describe sets of strings. They are used in virtually every programming language for searching, matching, and replacing text. A regex like \w+@\w+\.\w+ matches email addresses by specifying the pattern of characters before and after the @ symbol.

Common Regex Flags

The global flag (g) finds all matches instead of stopping at the first one. Case-insensitive (i) ignores uppercase/lowercase differences. Multiline (m) makes ^ and $ match line boundaries instead of string boundaries. Dotall (s) makes the dot character match newlines.

Privacy Advantage

This tool processes all patterns and test strings entirely in your browser. Your input is never sent to a server, so you can test patterns against sensitive data like API keys, personal information, or proprietary content. You can verify this in your browser's Network tab.

Frequently Asked Questions

What are the most common regex patterns?

Email validation: [\w.+-]+@[\w-]+\.[\w.]+. URL matching: https?://[\w.-]+(/[\w.-]*)*. Phone numbers: \+?\d{1,3}[-.\s]?\d{3,4}[-.\s]?\d{4}. IP addresses: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}. Dates: \d{4}-\d{2}-\d{2}. This tool lets you test any pattern against your own data instantly.

What do regex flags g, i, m, and s mean?

The g (global) flag finds all matches instead of stopping at the first. The i (case-insensitive) flag ignores uppercase/lowercase. The m (multiline) flag makes ^ and $ match line boundaries. The s (dotall) flag makes the dot match newlines. Toggle these flags in the pattern bar above.

Is my test data sent to a server?

No. ToolPry uses your browser's built-in JavaScript RegExp engine, so patterns and test strings are processed locally and never uploaded. ToolPry has no accounts and no save feature, so there is nothing to store. Open DevTools → Network while typing to confirm that no requests are made.

Can I generate code from my regex pattern?

Yes. After testing your pattern, click JavaScript, Python, or PHP to generate ready-to-use code snippets. The generated code includes the correct syntax for each language with your pattern and flags already applied.

How to Use the Regex Tester

Enter your regular expression in the pattern field and your test string in the text area. Matches are highlighted in real time as you type — no need to click a button. The match details panel shows each match's position, length, and capture group values, which is essential for debugging complex patterns with named or numbered groups.

Most Useful Regex Patterns (Copy-Ready)

Email address: /^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/ — covers 99%+ of real-world addresses. See our full guide: Email Validation Regex Complete Guide.

URL: /https?:\/\/[^\s<>"{}|\^[\]`]+/g — matches HTTP and HTTPS URLs in text.

IPv4 address: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/

ISO date (YYYY-MM-DD): /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/

Hex colour: /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/

Understanding Flags

The g (global) flag finds all matches, not just the first. The i (case-insensitive) flag ignores case so /hello/i matches "Hello", "HELLO", and "hello". The m (multiline) flag makes ^ and $ match line boundaries instead of string boundaries. The s (dotAll) flag makes . match newline characters, which it does not by default.

Frequently Asked Questions

Which regex engine does this tester use?

JavaScript's built-in RegExp engine (ECMAScript 2024). This is the correct engine for any pattern you intend to use in a browser, Node.js, or Deno application. For Python, Java, or .NET patterns, note that some syntax differs — particularly around lookaheads, named groups, and certain character class syntax.

How do I match a literal dot or plus sign?

Escape special characters with a backslash: \. matches a literal dot, \+ matches a literal plus. The characters . * + ? ^ $ {} [] | \ ( ) all have special meaning in regex and must be escaped to match literally.

Why does my pattern match more than I expect?

Quantifiers are greedy by default — they match as much as possible. Add ? after a quantifier to make it lazy (match as little as possible): .*? instead of .*. Also ensure you have anchors (^ at start, $ at end) if you want to match the entire string rather than a substring.