HTML BlogCode Manual & Tools

Regex Tester Online

Test regular expressions with live matching, capture groups, and replace mode. All processing runs in your browser.

/ /

Test String

Match Results

0 matches
Enter a pattern and test string to see matches

Capture Groups

No capture groups found

Replace Mode

Replace result will appear here...

How to Use the Regex Tester

  1. Enter your regex pattern in the pattern input field at the top. The pattern is automatically wrapped in forward slashes.
  2. Select flags using the checkboxes. The g (global) flag is enabled by default to find all matches. Enable i for case-insensitive matching, m for multiline mode, or s to make the dot match newlines.
  3. Type or paste your test string in the "Test String" area. Matches are highlighted in real time as you type.
  4. View match results on the right panel with alternating highlight colors for each match. The match count updates live.
  5. Inspect capture groups in the expandable table below. Each match shows the full match and all captured groups.
  6. Use Replace Mode to test search-and-replace operations. Enter a replacement string (you can use $1, $2 for captured groups) and click "Replace" to see the result.
  7. Browse Common Patterns for ready-to-use regex patterns for emails, URLs, IP addresses, and more.

What Are Regular Expressions?

Regular expressions (regex or regexp) are powerful sequences of characters that define search patterns. They are used across virtually every programming language and text editor for tasks like:

A simple regex like \d+ matches one or more digits, while [A-Za-z]+ matches one or more letters. You can combine these building blocks to create patterns that match complex text structures. Regular expressions are supported in JavaScript, Python, PHP, Java, C#, Ruby, Go, and most other programming languages.

Regex Cheat Sheet

PatternDescriptionExample
.Any character except newlinea.c matches "abc", "a1c"
*Zero or more of the preceding elementab*c matches "ac", "abc", "abbc"
+One or more of the preceding elementab+c matches "abc", "abbc" but not "ac"
?Zero or one of the preceding elementcolou?r matches "color", "colour"
^Start of string (or line in multiline mode)^Hello matches "Hello world"
$End of string (or line in multiline mode)world$ matches "Hello world"
[abc]Character class: matches a, b, or c[aeiou] matches vowels
[^abc]Negated class: any char except a, b, c[^0-9] matches non-digits
{n,m}Between n and m repetitions\d{2,4} matches 2 to 4 digits
()Capture group(\w+)@(\w+) captures user and domain
|Alternation (OR)cat|dog matches "cat" or "dog"
\dDigit (equivalent to [0-9])\d{3} matches "123"
\wWord character (letter, digit, underscore)\w+ matches "hello_123"
\sWhitespace (space, tab, newline)\s+ matches spaces between words
\bWord boundary\bcat\b matches "cat" but not "category"
(?=...)Positive lookahead\d+(?= dollars) matches "100" in "100 dollars"
(?!...)Negative lookahead\d+(?! dollars) matches digits not before " dollars"
(?:...)Non-capturing group(?:ab)+ matches "abab" without capturing

Common Regex Patterns

Email Address

[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

Matches standard email addresses like [email protected]. Validates the local part, @ symbol, domain, and TLD.

URL (HTTP/HTTPS)

https?:\/\/[^\s/$.?#].[^\s]*

Matches HTTP and HTTPS URLs. Captures the protocol, domain, path, and query parameters.

IPv4 Address

\b(?:\d{1,3}\.){3}\d{1,3}\b

Matches IPv4 addresses like 192.168.1.1. Each octet can be 1-3 digits. Does not validate the 0-255 range.

Phone Number (US)

\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}

Matches US phone numbers in various formats: (555) 123-4567, 555-123-4567, 555.123.4567.

Date (YYYY-MM-DD)

\d{4}[-/]\d{2}[-/]\d{2}

Matches dates in ISO format like 2026-03-19 or 2026/03/19. Accepts hyphens or slashes as separators.

HTML Tag

<([a-z][a-z0-9]*)\b[^>]*>(.*?)<\/\1>

Matches opening and closing HTML tags with content between them. Uses a backreference to match the closing tag.

Hex Color Code

#(?:[0-9a-fA-F]{3}){1,2}\b

Matches 3-digit and 6-digit hex color codes like #fff, #FF5733, #e94560.

Password Strength

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{8,}$

Validates strong passwords: at least 8 characters with uppercase, lowercase, digit, and special character.

Username

^[a-zA-Z0-9_-]{3,20}$

Validates usernames: 3-20 characters, letters, numbers, underscores, and hyphens only.

Whitespace Cleanup

\s{2,}

Matches two or more consecutive whitespace characters. Useful for cleaning up text with extra spaces.

Frequently Asked Questions

What is a regular expression (regex)?

A regular expression is a sequence of characters that defines a search pattern. Regex is used for string matching, validation, search-and-replace, and text extraction in programming and text editors. Most programming languages including JavaScript, Python, PHP, and Java support regex natively.

Is my data safe when using this regex tester?

Yes, absolutely. All processing happens entirely in your browser using JavaScript. No data is sent to any server. Your text and regex patterns never leave your computer. You can even use this tool offline once the page is loaded.

What regex flavors does this tool support?

This tool uses the native JavaScript RegExp engine built into your browser. It supports all standard regex features including capture groups, named groups, lookaheads, lookbehinds (in modern browsers), and Unicode properties. JavaScript regex syntax is very similar to most other languages.

How do capture groups work in regex?

Capture groups are created by placing part of a regex pattern inside parentheses (). When a match is found, the text matched by each group is captured separately, allowing you to extract specific parts of the matched text. Use $1, $2, etc. in replacement strings to reference captured groups. Non-capturing groups (?:...) group without capturing.

Can I use this tool to test regex for other programming languages?

JavaScript regex syntax is very similar to regex in most other languages (Python, PHP, Java, C#). Most basic and intermediate patterns work the same way across languages. However, some advanced features like possessive quantifiers (++), atomic groups ((?>...)), or conditional patterns are not supported in JavaScript regex.