Skip to content

Online Regex Tester - Regular Expression Debugger

Working with regex? This online regex tester helps you test and debug regular expressions instantly. Just enter your pattern, add flags, and paste test text to see:

  • Live highlighting of matches in your text
  • Capture groups with detailed results
  • JSON output of all matches
  • Presets for common regex patterns

Regex Pattern & Settings

Regex Presets

Regex FlagsCurrent flags:/g

Results

No matches found

Try adjusting your regex pattern or test text to find matches.

Understanding Regular Expressions

Regular expressions (regex) are powerful pattern-matching tools used in programming, data validation, text parsing, and search operations. Test pattern strings, match objects, single character matching, replacement strings, and capture groups with our free regex debugger.

Regular expressions are essential tools for developers working with text processing, data validation, and pattern matching across all programming languages. Whether you're building form validation in JavaScript, parsing log files in Python, processing user input in PHP, or extracting data in Java, regex provides a concise syntax for complex text matching operations.

A regex pattern combines literal text with special metacharacters to define matching rules. For example, the pattern \d{3}-\d{2}-\d{4} matches US Social Security numbers by specifying exactly three digits, a hyphen, two digits, another hyphen, and four digits. The \d metacharacter represents any digit (0-9), while {3} specifies exactly three repetitions. Common regex patterns include email validation with [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}, URL matching, phone number formats, and credit card validation.

Developers use regex for input sanitization, data extraction from unstructured text, find-and-replace operations in code editors, log file parsing, and web scraping. Understanding quantifiers like * (zero or more), + (one or more), and ? (zero or one) enables flexible pattern matching. Anchors such as ^ (start of string) and $ (end of string) ensure patterns match at specific positions.

Character classes like [A-Za-z] match letter ranges, while negated classes [^0-9] match anything except digits. Our regex tester provides real-time feedback on pattern matching, highlighting matches directly in your test text, displaying capture groups for data extraction, and showing JSON output for programmatic use. Test your patterns with different flags to see how global, case-insensitive, and multiline modes affect matching behavior before implementing them in production code.

Regular Expression Fundamentals

What is a regular expression (regex)?
A regular expression is a sequence of characters that defines a search pattern for text. Regex patterns are used for pattern matching, validation, parsing, and text manipulation in programming languages like JavaScript, Python, PHP, and Java. They consist of literal characters (like"abc") and metacharacters (special symbols like ., *, +, ?, [], {}, ^, $) that define matching rules.
What are the most common regex metacharacters?
Common metacharacters include: dot (.) matches any single character except newline; asterisk (*) matches 0 or more of the preceding element; plus (+) matches 1 or more; question mark (?) matches 0 or 1; brackets [] define character classes; parentheses () create capture groups; caret (^) matches start of line; dollar sign ($) matches end of line; pipe (|) acts as OR operator; backslash (\) escapes special characters.
How do character classes work in regex?
Character classes use square brackets to match any one character from a set. [abc] matches a, b, or c. [a-z] matches any lowercase letter. [0-9] matches any digit. [^abc] matches any character except a, b, or c (negated class). Predefined classes include \d (digits), \w (word characters: letters, digits, underscore), \s (whitespace), and their uppercase negations \D, \W, \S.
What is the difference between greedy and lazy matching?
Greedy quantifiers (*, +, {n,}) match as much text as possible. For example, .* in"abc123xyz" matches the entire string. Lazy (non-greedy) quantifiers (*?, +?, {n,}?) match as little as possible. .*? matches the shortest possible string. In HTML tag matching, <.*> greedily matches from first < to last >, while <.*?> correctly matches individual tags.
How do capture groups and backreferences work?
Parentheses () create numbered capture groups that store matched text for later use. In (\d{3})-(\d{2})-(\d{4}), three groups capture phone number parts. Backreferences like \1, \2 refer to captured groups within the same pattern. (\w+)\s+\1 matches repeated words. Named groups (?<name>pattern) provide clearer references than numbers.
What are lookaheads and lookbehinds in regex?
Lookaheads and lookbehinds are zero-width assertions that check for patterns without consuming characters. Positive lookahead (?=pattern) asserts pattern exists ahead. \d(?=px) matches digits followed by"px". Negative lookahead (?!pattern) asserts pattern does not exist. Positive lookbehind (?<=pattern) checks pattern behind. Negative lookbehind (?<!pattern) asserts pattern is not behind current position.
How do regex flags modify pattern matching behavior?
Flags change how the regex engine processes patterns. Global flag (g) finds all matches instead of stopping at first match. Case-insensitive flag (i) ignores letter case. Multiline flag (m) makes ^ and $ match line boundaries within text. Dotall flag (s) makes dot (.) match newline characters. Unicode flag (u) enables full Unicode support. Sticky flag (y) matches only from lastIndex position.
What are common use cases for regular expressions?
Regular expressions excel at: validating input formats (email addresses, phone numbers, URLs, credit cards); extracting data from text (parsing logs, scraping HTML); find-and-replace operations with pattern-based substitution; tokenizing and parsing structured data; cleaning and normalizing text; validating password strength; syntax highlighting in code editors; and search functionality with advanced pattern matching beyond simple string search.

Privacy-focused

  • Free forever
  • No account required
  • Privacy-focused

All regex testing happens in your browser. No data is sent to our servers or stored anywhere. Your patterns and test text remain completely private.

More tools

All tools
  • Tool

    API Response Mocker

    Generate realistic mock API responses with dynamic data using Faker.js. 17 pre-built templates for testing and development.

  • Tool

    Tech Pulse

    Tech news feed for developers, sorted by topic. Get the latest AI, Cloud, DevOps, and Security headlines in one place.

  • Tool

    Resume Optimizer

    Transform your resume for ATS compliance with AI-powered optimization. Upload and download improved DOCX/PDF versions.

  • Tool

    DNS Lookup

    Comprehensive DNS record lookup with native and DoH support, email security analysis, and export options.

  • Tool

    QR Code Generator

    Create customizable QR codes for URLs, text, email, phone, and WiFi. Download as PNG or SVG.