DevUtilityToolsDevUtilityTools

Free Online Regex Tester

Test regular expressions in real time with highlighted matches, capture groups, and full flag support. 100% browser-based — your data never leaves your device.

Ad Space
/
/gi
Try:
Test String0 chars
Match Results
0 matches
Matches will appear here...
Ad Space

What is Regex?

Regular expressions (regex or regexp) are sequences of characters that define search patterns. They are used in programming, text editors, and command-line tools to find, match, and manipulate strings of text based on specific rules.

Regex is one of the most powerful tools in a developer's toolkit. From validating email addresses and phone numbers to extracting data from logs, regular expressions are used across virtually every programming language and platform.

Regex Basics — Cheat Sheet

Character Classes
  • \d — Any digit (0-9)
  • \w — Word character (a-z, A-Z, 0-9, _)
  • \s — Whitespace (space, tab, newline)
  • . — Any character (except newline)
  • [abc] — Any of a, b, or c
  • [^abc] — Not a, b, or c
Quantifiers
  • * — 0 or more
  • + — 1 or more
  • ? — 0 or 1
  • {n} — Exactly n times
  • {n,m} — Between n and m times
  • *? — Lazy (non-greedy) match
Anchors & Boundaries
  • ^ — Start of string / line
  • $ — End of string / line
  • \b — Word boundary
  • \B — Not a word boundary
Groups & Lookaround
  • (abc) — Capture group
  • (?:abc) — Non-capturing group
  • (?=abc) — Lookahead
  • (?!abc) — Negative lookahead
  • (?<=abc) — Lookbehind
  • (?<!abc) — Negative lookbehind

Common Regex Patterns

Email

Validate email addresses with a common pattern: ^[^\s@]+@[^\s@]+\.[^\s@]+$

Phone Number

Match US phone numbers: \(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}

URL

Match HTTP/HTTPS URLs: https?:\/\/[^\s]+

Why Use This Tool?

  • Real-Time Testing: See matches highlighted instantly as you type your pattern and test string.
  • Capture Groups: View detailed match information including all captured groups, match indices, and full match text.
  • Privacy First: Everything runs locally in your browser. We never see your data or patterns.
  • Quick Presets: Start testing immediately with common patterns for email, URL, and date validation.
  • Flag Support: Toggle global, case-insensitive, multiline, and dotAll flags with a single click.
Ad Space

Frequently Asked Questions

Is this Regex Tester secure and private?

Yes, completely. All regex matching happens entirely in your browser using JavaScript. No data is sent to any server, so your patterns and test strings remain private on your device.

What regex flags are supported?

This tool supports four commonly used flags: g (global — find all matches), i (case-insensitive matching), m (multiline — ^ and $ match line boundaries), and s (dotAll — dot matches newline characters).

What are capture groups in regex?

Capture groups are portions of a regex pattern enclosed in parentheses (). They allow you to extract specific parts of a match. For example, in the pattern (\d{4})-(\d{2})-(\d{2}), there are three capture groups that extract the year, month, and day from a date string.

Why does my regex match nothing?

Common reasons include: the pattern has a syntax error, the flags don't match your intent (e.g., missing the 'i' flag for case-insensitive matching), or special characters aren't properly escaped. Check the error message if one appears, and ensure characters like . * + ? are escaped with a backslash if you want to match them literally.

What is the difference between .* and .*? in regex?

.* is greedy — it matches as many characters as possible. .*? is lazy (non-greedy) — it matches as few characters as possible. For example, given the string '<b>hello</b>', the pattern <.*> matches the entire string, while <.*?> matches only '<b>'.

Can I use this tool for regex in any programming language?

This tool uses JavaScript's RegExp engine, which is compatible with most common regex patterns. However, some advanced features like lookbehinds (supported in modern browsers), atomic groups, or possessive quantifiers may behave differently in other languages like Python, Java, or Perl.