Regex Tester

Test your regular expressions with real-time match highlighting and capture group inspection. Toggle flags, paste your test string, and see every match the moment you type.

How to Use This Tool

  1. Enter a pattern in the pattern field above (e.g. \d+ to match numbers).
  2. Select flags — toggle global (g), case-insensitive (i), multiline (m) or dotAll (s) as needed for your use case.
  3. Paste your test string into the text area below the pattern input.
  4. View matches — matched portions are highlighted in the results panel and any capture groups are listed separately.
  5. Clear — click "Clear" to reset the pattern, test string and all results.

What Are Regular Expressions?

Regular expressions (regex or regexp) are sequences of characters that define a search pattern. They are supported in virtually every programming language and text editor, and they power features like find-and-replace, input validation, log parsing and data extraction. A regex pattern can match literal characters, character classes (such as digits or whitespace), repetitions, alternations and positional anchors, giving you precise control over what text you want to find.

Flags modify how the regex engine processes a pattern. The global flag (g) tells the engine to find every match in the string rather than stopping after the first. The case-insensitive flag (i) treats uppercase and lowercase letters as equivalent. The multiline flag (m) changes the meaning of ^ and $ so they match the start and end of each line instead of the entire string. The dotAll flag (s) allows the dot metacharacter to match newline characters, which it skips by default.

Common use cases include validating email addresses and phone numbers in form inputs, extracting structured data from semi-structured text like log files and CSV exports, performing bulk search-and-replace operations in codebases, and writing URL routing rules in web frameworks. Learning regex is one of the highest-leverage skills a developer can invest in because it applies across languages, tools and platforms.

Frequently Asked Questions

What do the regex flags mean?
The four most common flags are: g (global) finds all matches instead of just the first; i (case-insensitive) ignores letter casing; m (multiline) makes ^ and $ match line boundaries rather than string boundaries; and s (dotAll) lets . match newline characters. You can combine them freely depending on your requirements.
Why isn't my regex matching anything?
The most frequent causes are: forgetting to enable the global (g) flag so only the first match appears, not escaping special characters like ., (, ) or [ that have special meaning in regex syntax, using anchors like ^ and $ without the multiline flag on multi-line text, or a simple typo. Try reducing your pattern to a minimal version and building it back up incrementally to isolate the problem.
What is the difference between .* and .*? (greedy vs lazy)?
.* is greedy and matches as many characters as possible while still allowing the overall pattern to succeed. .*? is lazy (reluctant) and matches as few characters as possible. For instance, against the text <b>hello</b>, the pattern <.*> greedily matches the entire string, while <.*?> lazily matches only <b>. Use lazy quantifiers when you want the shortest match between delimiters.
What is a regular expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. It is used in programming and text processing to find, match, and manipulate strings. Regular expressions are supported in virtually every programming language, text editor, and command-line tool, making them one of the most versatile tools in a developer's toolkit.
What are regex flags?
Regex flags are optional parameters that modify how the regex engine processes a pattern. Common flags include g (global) to find all matches, i (case-insensitive) to ignore letter casing, m (multiline) to make anchors match line boundaries, and s (dotAll) to let the dot match newline characters. Flags can be combined to fine-tune matching behavior for your specific use case.
What is a capture group?
A capture group is a portion of a regex pattern enclosed in parentheses that extracts a specific part of the matched text. For example, the pattern (\d{3})-(\d{4}) applied to "555-1234" captures "555" in group 1 and "1234" in group 2. Capture groups are useful for extracting substrings, performing replacements, and validating structured input like dates and phone numbers.
What is the difference between greedy and lazy matching?
Greedy matching (the default) consumes as many characters as possible while still allowing the overall pattern to succeed. Lazy matching, triggered by adding a ? after a quantifier, consumes as few characters as possible. For example, given <b>hello</b>, the greedy pattern <.*> matches the entire string, while the lazy pattern <.*?> matches only <b>. Choose lazy matching when you need the shortest possible match between delimiters.