Regex Tester

Test regular expressions with real-time matching, capture groups, and multi-language code snippets.

Common Patterns:
Pattern
/.../g
//g
Flags:
Test String
0 chars
Match Highlighting
Enter a test string above...
Match Details
Enter a pattern to start matching.
Code Snippets
// Enter a regex pattern to see code snippets

How 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.

PatternRegexDescription
Email[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}Match email addresses
URLhttps?:\/\/[^\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}\bMatch 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 range

Quantifiers

*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 lookbehind

Groups & 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.