Regex Tester
Test regular expressions with real-time matching, capture groups, and multi-language code snippets.
// Enter a regex pattern to see code snippetsHow to Use the Regex Tester
This online regex tester lets you build and test regular expressions in real time. Enter a pattern in the pattern field, type or paste your test string below, and see matches highlighted instantly. No server calls are made -- everything runs in your browser.
1. Enter a Pattern
Type your regular expression in the pattern input field. Use the flag toggle buttons (g, i, m, s, u) to set matching modes. The pattern is displayed in standard regex notation.
2. Provide Test Text
Paste or type the string you want to test against. You can also select a common preset pattern to auto-fill both the pattern and a sample test string.
3. Review Matches
Matches are highlighted in the preview panel with different colors. The details panel shows each match with its capture groups, named groups, and index positions.
4. Export Code
Switch between JavaScript, Python, Java, and Go tabs to see ready-to-use code snippets for your pattern. Copy the code directly into your project.
Common Regular Expression Patterns
Here are some of the most frequently used regex patterns for everyday development tasks. Click any of the preset buttons above the tool to try them instantly.
| Pattern | Regex | Description |
|---|---|---|
[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,} | Match email addresses | |
| URL | https?:\/\/[^\s]+ | Match HTTP/HTTPS URLs |
| Phone | \+?[\d\s\-().]{7,} | Match phone numbers |
| IP Address | \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b | Match IPv4 addresses |
| Date (YYYY-MM-DD) | \d{4}-\d{2}-\d{2} | Match ISO date format |
| Hex Color | #([a-fA-F0-9]{6}|[a-fA-F0-9]{3}) | Match hex color codes |
Regex Cheat Sheet
Character Classes
.Any character (except newline)\dDigit [0-9]\DNon-digit\wWord character [a-zA-Z0-9_]\WNon-word character\sWhitespace\SNon-whitespace[abc]Character set (a, b, or c)[^abc]Negated set (not a, b, or c)[a-z]Character rangeQuantifiers
*0 or more+1 or more?0 or 1 (optional){n}Exactly n{n,}n or more{n,m}Between n and m*?0 or more (lazy)+?1 or more (lazy)Anchors & Boundaries
^Start of string/line$End of string/line\bWord boundary\BNon-word boundary(?=...)Positive lookahead(?!...)Negative lookahead(?<=...)Positive lookbehind(?<!...)Negative lookbehindGroups & References
(abc)Capture group(?:abc)Non-capturing group(?<name>)Named capture group\1Backreference to group 1(a|b)Alternation (a or b)Frequently Asked Questions
Is my data sent to a server?
No. All regex matching and code generation happens entirely in your browser using JavaScript. Your test strings and patterns never leave your device.
Which regex flavor does this tool use?
This tool uses JavaScript's built-in RegExp engine, which supports ECMAScript 2024 regex features including named capture groups, lookbehind assertions, and the Unicode flag. The generated code snippets adapt the pattern to each language's native regex syntax.
What do the regex flags mean?
g (global) finds all matches instead of stopping at the first. i (case-insensitive) ignores letter casing. m (multiline) makes ^ and $ match line boundaries. s (dotall) allows . to match newline characters. u (unicode) enables full Unicode matching and makes \w, \d etc. Unicode-aware.
How do capture groups work?
Parentheses () create capture groups that extract sub-matches. For example, (\d{4})-(\d{2})-(\d{2}) captures year, month, and day separately. Named groups use (?<name>...) syntax. Groups are shown in the Match Details panel with their index or name.
Can I use this regex pattern in other programming languages?
Yes. While the tester uses JavaScript regex, most patterns work across languages. Use the Code Snippets tabs to get ready-to-use code for JavaScript, Python, Java, and Go. Note that some advanced features like lookbehind may have limited support in older engines.
Related Tools
Format, validate, and beautify JSON with tree view and TypeScript type generation.
Generate UUID v4, v7, ULID, and Nano ID with bulk generation and format options.
Encode and decode text, images, and files to Base64 with real-time conversion.
Decode, inspect, and verify JWT tokens with claim explanations and expiration check.