HubTools

Regex Tester

Test and debug regular expressions with real-time matching, replacement, and splitting.

What is a Regular Expression?

A regular expression (regex) is a compact pattern syntax for describing sets of strings — used to validate input, search and extract substrings, and perform structured find-and-replace across text. The notation traces back to Stephen Kleene's 1956 work on regular sets, was popularized by Ken Thompson's 1968 grep implementation, and now ships in every major programming language, text editor, and database. Regex is the lingua franca for email/URL validation, log scraping, code search, route matching, and data cleanup. This tester runs JavaScript's native RegExp engine entirely in your browser with live match highlighting, capture group inspection, and match/replace/split modes. Need to apply your regex across multiple files? Use the Find & Replace tool. Comparing two text versions? Try the Diff Checker.
Pattern
//g
Global (g)
Case Insensitive (i)
Multiline (m)
DotAll (s)
Unicode (u)
Test String
Results
Enter a pattern and test string to see matches.
Common Patterns
  • Email

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

    https?://[^\s]+
  • Phone (US)

    \(?[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-9]{4}
  • IP Address

    \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b
  • Date (YYYY-MM-DD)

    \d{4}-\d{2}-\d{2}
  • Hex Color

    #[0-9a-fA-F]{6}
Quick Reference
TokenDescription
\dDigit (0-9)
\DNon-digit
\wWord character (a-z, A-Z, 0-9, _)
\WNon-word character
\sWhitespace
\SNon-whitespace
.Any character (except newline)
^Start of string/line
$End of string/line
*0 or more
+1 or more
?0 or 1 (optional)
{n}Exactly n times
{n,m}Between n and m times
[abc]Character class
[^abc]Negated character class
(abc)Capturing group
(?:abc)Non-capturing group
a|bAlternation (a or b)
\bWord boundary

How to use this tool

  1. 1
    Enter your pattern and flags
    Type the pattern and toggle flags (g, i, m, s, u, y, d) as needed. Invalid patterns surface a syntax error immediately.
  2. 2
    Paste your test input
    Drop the text you want to match against. Matches highlight in real time and capture groups are listed individually for inspection.
  3. 3
    Switch to replace or split
    Use the Replace tab to preview substitutions with backreferences ($1, $2), or the Split tab to see how the pattern segments your input.

Frequently asked questions

What regex flavor does this use?
JavaScript's native RegExp engine (ECMAScript 2018+). It supports lookahead, lookbehind, named capture groups, Unicode property escapes (\p{...}), and the d flag for match indices. Patterns from PCRE, Python, or .NET may need adjustment.