Regex Tester

Test regular expressions with real-time match highlighting and capture groups. 100% client-side.

/ / g
Test String
Highlighted Matches
Match Details
Enter a regex pattern and test string to find matches.

How to Use the Regex Tester

  1. Enter your regex pattern in the pattern field at the top. Do not include the surrounding slashes or flags — those are handled separately.
  2. Select flags by clicking the flag chips. The g (global) flag is enabled by default to find all matches. Flags toggle independently.
  3. Type or paste your test string in the textarea below. Matches are highlighted in real time as you type.
  4. Review matches — the highlighted output shows matches marked in yellow, and the match table below lists each match with its index position and capture groups.

Understanding Regular Expressions

Regular expressions are one of the most powerful tools in a developer's arsenal. They provide a concise and flexible way to search, match, and manipulate text. Every programming language has some form of regex support, and mastering regex patterns can dramatically improve your ability to process text data, validate user input, and parse structured content.

Common Regex Patterns

  • Email validation: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
  • URL matching: https?://[^\s/$.?#].[^\s]*
  • IP address: \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b
  • Phone number: \(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}
  • Date (YYYY-MM-DD): \d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])
  • Hex color: #(?:[0-9a-fA-F]{3}){1,2}\b

Once you have validated your text with regex, you may want to compare results using our Diff Checker or transform text casing with the Case Converter. For structured data validation, try the JSON Formatter.

Regex Flags Explained

JavaScript supports several flags that modify how the regex engine behaves. The g (global) flag finds all matches instead of returning after the first match. The i (case-insensitive) flag treats uppercase and lowercase letters as equivalent. The m (multiline) flag changes the behavior of ^ and $ so they match the start and end of each line rather than the entire string. The s (dotAll) flag allows the dot . to match newline characters. The u (unicode) flag enables full Unicode matching.

Capture Groups

Parentheses in a regex create capture groups that extract specific parts of a match. For example, the pattern (\d{4})-(\d{2})-(\d{2}) applied to "2026-03-22" captures three groups: "2026", "03", and "22". Named capture groups using (?<name>...) syntax make your regex more readable and the extracted values easier to reference in code. This tool displays all capture groups in the match details table.

Performance Considerations

Regex engines can exhibit catastrophic backtracking on certain patterns, causing extreme slowness. Avoid nested quantifiers like (a+)+ or (a*)*. Be specific with your character classes rather than using broad wildcards. When matching large texts, prefer non-greedy quantifiers (*?, +?) when possible to reduce unnecessary backtracking.

Lookaheads and Lookbehinds

Lookaheads ((?=...) for positive, (?!...) for negative) and lookbehinds ((?<=...) for positive, (?<!...) for negative) match positions without consuming characters. For example, \d+(?= dollars) matches the number in "100 dollars" but not in "100 euros". Lookbehinds work similarly but check what precedes the current position. These are powerful for extracting data from structured text without including surrounding context in the match. Note that JavaScript lookbehinds require a modern browser (Chrome 62+, Firefox 78+, Safari 16.4+).

Frequently Asked Questions

A regular expression (regex) is a sequence of characters that defines a search pattern. Regexes are used in programming and text processing to find, match, validate, and replace text. Common use cases include form validation (email, phone), log parsing, data extraction, and search-and-replace operations.
The g (global) flag finds all matches instead of stopping after the first. The i (case-insensitive) flag ignores letter case. The m (multiline) flag makes ^ and $ match the start and end of each line. The s (dotAll) flag makes . match newline characters. The u (unicode) flag enables full Unicode matching including surrogate pairs.
No. This regex tester runs 100% in your browser using JavaScript's built-in RegExp engine. Your patterns and test strings never leave your machine. There is no server-side processing, no logging, and no data collection.
This tool uses JavaScript's built-in RegExp engine, which supports standard regex syntax including character classes, quantifiers, anchors, groups, lookahead, lookbehind (in modern browsers), backreferences, and Unicode property escapes with the u flag. Some features like possessive quantifiers or atomic groups from PCRE are not supported.
Wrap the parts of your regex you want to capture in parentheses, for example (\d+)-(\w+). The match table below the highlighted output will show each match along with its captured groups. Named groups like (?<name>\w+) are also supported and displayed by their group name.