Regex Tester

Test and debug regular expressions with real-time matching and detailed explanations

Regular Expression
Pattern
//
Replacement String
Test String0 characters
Result
Matches will be highlighted here...
Matches:0
Groups:0
Time:0ms
Quick Reference

What is Regex?

Regular expressions (regex) are powerful sequences of characters that define search patterns. They're used extensively in programming for text searching, validation, and manipulation. This tool helps you build, test, and debug regex patterns in real-time.

Our regex tester uses JavaScript's regex engine and supports all modern regex features including lookaheads, lookbehinds, capturing groups, and Unicode properties.

Real-Time Testing

See matches highlighted instantly as you type your pattern

Visual Highlighting

Matches are color-coded for easy identification

Group Extraction

View captured groups with detailed match information

Replace & Split

Test substitutions and string splitting with your pattern

How to Use This Tool

  1. Enter your regex pattern in the pattern input field
  2. Select flags (g, i, m, s, u) as needed for your use case
  3. Type or paste test text in the test string area
  4. View results - matches are highlighted and detailed in the results panel
  5. Use Replace mode to test substitutions with $1, $2 for groups

Common Regex Patterns

  • ^ - Start of string/line
  • $ - End of string/line
  • . - Any character except newline
  • \d - Any digit (0-9)
  • \w - Any word character (a-z, A-Z, 0-9, _)
  • \s - Any whitespace character
  • [abc] - Any character in the set
  • [^abc] - Any character not in the set
  • a* - Zero or more of 'a'
  • a+ - One or more of 'a'
  • a? - Zero or one of 'a'
  • a{3} - Exactly 3 of 'a'
  • (abc) - Capturing group
  • (?:abc) - Non-capturing group

Frequently Asked Questions (FAQs)

A regular expression (regex) is a sequence of characters that defines a search pattern. It's used for pattern matching within strings, text search and replace, input validation, and data extraction. Regex is supported in most programming languages.

g (global) - Find all matches, not just the first. i (case-insensitive) - Match regardless of case. m (multiline) - ^ and $ match start/end of each line. s (dotall) - Dot matches newline characters. u (unicode) - Enable unicode support.

Special characters like . * + ? ^ $ { } [ ] \ | ( ) need to be escaped with a backslash. For example, to match a literal dot, use \. instead of just a dot. To match a backslash itself, use \\.

Capturing groups are created with parentheses () and allow you to extract specific parts of a match. For example, (\d{3})-(\d{4}) matching "123-4567" creates two groups: "123" and "4567". Use $1, $2 etc. to reference them in replacements.

Greedy quantifiers (*, +, ?) match as much as possible, while lazy quantifiers (*?, +?, ??) match as little as possible. For example, with the text "aaa", the pattern a+ matches "aaa" (greedy), while a+? matches just "a" (lazy).

Online JSON Formatter