Regex Tester

Enter a regular expression and test string below to see matches highlighted in real time. View capture groups, match counts, and flags — all processed locally in your browser.

/ / g

How to Use the Regex Tester

Regular expressions (regex) are powerful patterns used to search, match, and manipulate text in virtually every programming language. Whether you are validating email addresses, parsing log files, or extracting data from HTML, this free online regex tester lets you experiment with patterns and see results instantly — no compilation or code execution needed.

  1. Enter your pattern: Type your regular expression in the pattern field. You do not need to include the surrounding slashes — just the pattern itself.
  2. Select flags: Toggle the checkboxes to enable global matching (g), case-insensitive mode (i), multiline mode (m), or dotAll mode (s) depending on your use case.
  3. Paste your test string: Enter sample text in the textarea. Matches highlight instantly as you type in either field.
  4. Review results: The highlighted output shows every match in context. Capture groups are listed below, showing exactly which parts of the text each group captured.

Understanding Common Regex Syntax

PatternDescriptionExample Match
.Any character except newlinea.c matches "abc"
\dAny digit (0–9)\d{3} matches "123"
\wWord character (letter, digit, underscore)\w+ matches "hello_42"
\sWhitespace (space, tab, newline)\s+ matches " "
^ / $Start / end of string (or line with m flag)^Hello matches "Hello world"
[abc]Character class — matches a, b, or c[aeiou] matches vowels
(group)Capture group(\d+)-(\d+) captures two number groups
a|bAlternation — matches a or bcat|dog matches either word
{n,m}Quantifier — between n and m times\d{2,4} matches 2–4 digits

Tips for Writing Better Regular Expressions

Regular expressions can become complex quickly. Start with a simple pattern that matches the core of what you need, then add specificity. Use non-greedy quantifiers (*?, +?) when you want the shortest possible match. Named capture groups ((?<name>...)) make your patterns more readable and your code easier to maintain. Always test with edge cases — empty strings, strings with special characters, and very long inputs — to make sure your pattern is robust.

This tool uses the JavaScript RegExp engine, which supports most modern regex features including lookahead, lookbehind, and Unicode property escapes. Results may differ slightly from regex engines in other languages like Python, Java, or PCRE.

Frequently Asked Questions

How do I test a regular expression online?

Type your regex pattern in the pattern input field, select the flags you need (global, case-insensitive, multiline, or dotAll), then enter or paste your test string in the textarea below. Matches are highlighted instantly as you type, with a running count and capture group details displayed beneath the output.

What are regex flags and when should I use them?

Flags modify how the regex engine processes your pattern. The 'g' (global) flag finds all matches instead of stopping at the first one. The 'i' flag makes matching case-insensitive. The 'm' (multiline) flag lets ^ and $ match the start and end of each line. The 's' (dotAll) flag makes the dot (.) match newline characters as well.

How do capture groups work in regex?

Capture groups are created by wrapping part of your pattern in parentheses, for example (\d{3})-(\d{4}). Each group captures the text that matched that portion of the pattern. This tool lists all capture groups for every match so you can verify your extraction logic before writing code.

Why is my regex not matching anything?

Common reasons include forgetting the global flag (so only the first match is found), escaping issues (backslashes need to be doubled in some contexts), or the pattern is too specific. Check that your flags are correct and try simplifying the pattern to isolate the problem.

Is my data sent to a server?

No. All regex processing happens entirely in your browser using the native JavaScript RegExp engine. Your patterns and test strings never leave your device.