DevToys Web Pro

free web developer tools

Blog
Rate us:
Try browser extension:

Regular Expression Tester

Configuration

Pattern

Test String

  • Matches

    Enter a pattern to see matches

    Replace

    Reference

    Character classes

    .Any character except newline
    [abc]Match a, b, or c
    [^abc]Match anything except a, b, c
    [a-z]Character range (a to z)
    \dDigit (0-9)
    \DNon-digit
    \wWord character [a-zA-Z0-9_]
    \WNon-word character
    \sWhitespace
    \SNon-whitespace

    Anchors

    ^Start of string/line
    $End of string/line
    \bWord boundary
    \BNon-word boundary

    Escaped characters

    \tTab
    \nNewline
    \rCarriage return
    \0Null character
    \xhhHex character (e.g. \xFF)
    \uhhhhUnicode character

    Groups & References

    (abc)Capturing group
    (?:abc)Non-capturing group
    (?<name>abc)Named capturing group
    \1Back-reference to group 1
    \k<name>Back-reference to named group

    Lookaround

    (?=abc)Positive lookahead
    (?!abc)Negative lookahead
    (?<=abc)Positive lookbehind
    (?<!abc)Negative lookbehind

    Quantifiers & Alternation

    a*0 or more (greedy)
    a+1 or more (greedy)
    a?0 or 1 (optional)
    a{n}Exactly n times
    a{n,}n or more times
    a{n,m}Between n and m times
    a*?0 or more (lazy)
    a+?1 or more (lazy)
    a|bMatch a or b

    Substitution

    $1, $2Captured group content
    $&Entire match
    $`Before match
    $'After match
    $$Literal $ character
    Technical details

    How the RegEx Tester Works

    What the Tool Does

    The regex tester allows you to test regular expressions against sample text in real-time. It functions as both a regex debugger and regex validator, helping developers build, test, and refine pattern matching expressions. This tester uses the JavaScript RegExp engine (ECMAScript), so syntax may differ from PCRE, .NET, or Java regex engines. When you need to test regex online, this tool shows all matches, capture groups, and replacements. The tool supports JavaScript regex syntax including JavaScript regex flags (g, i, m, s, u): global (g), case-insensitive (i), multiline (m), dotAll (s), and unicode (u). It highlights matches in the test string, displays capture groups, and can perform find-and-replace operations to preview how a regex would transform text.

    Common Developer Use Cases

    Developers use regex testers when building validation patterns, parsing log files, or extracting data from strings. Testing regexp patterns helps identify edge cases, debug complex expressions, and understand how different flags affect matching behavior. Many developers use regex testers to validate email addresses, phone numbers, URLs, or other structured data formats. The tool is valuable when working with form validation, log analysis, or text processing tasks. Regex testers also help when learning regular expressions, as they show how patterns match text through match iteration and group extraction. When testing regexp with multiline text or special characters, the tool helps developers see exactly what gets matched and why.

    Data Formats, Types, or Variants

    Regex testers handle JavaScript regular expression syntax, which is based on Perl-style regex with some differences from other regex engines. The tool supports character classes like \d for digits, \w for word characters, and \s for whitespace. It handles anchors (^, $), quantifiers (*, +, ?), and alternation (|). The multiline flag affects how ^ and $ match, while the dotAll flag makes . match newline characters. Understanding regex new line behavior is crucial for multiline text processing. For example, testing a pattern like /\d3-\d3-\d4/ against a phone number string shows exactly which parts match. Regex new line handling depends on flags: the pattern ^foo.*bar$ matches "foo\nbar" only with the dotAll flag (s), since . doesn't match newlines by default. When working with regex new line patterns, use \n to match literal newlines, or \r\n for Windows line endings.

    Common Pitfalls and Edge Cases

    One common mistake is forgetting that JavaScript regex uses forward slashes as delimiters, not quotes. Another issue is misunderstanding how the global flag affects matching: without it, only the first match is returned, but with it, all matches are found. Regex new line handling can be tricky: the . character doesn't match newlines by default unless the dotAll flag is used. Character class negation with [^...] can be confusing, as it matches any character not in the class. Greedy vs lazy quantifiers (* vs *?) behave differently and can cause unexpected results. Lookahead and lookbehind assertions ((?=...), (?<=...)) are powerful but can be difficult to debug. Developers should test regex patterns with various inputs, including edge cases like empty strings, special characters, and unicode characters.

    When to Use This Tool vs Code

    Use this regex tester for quick pattern development, debugging complex expressions, or learning regular expression syntax. It's ideal for testing regex patterns before implementing them in code, especially when working with unfamiliar syntax or complex patterns. The visual feedback helps identify why a pattern matches or doesn't match specific text. For production code, use regex testers integrated into IDEs or unit testing frameworks that can validate patterns as part of your test suite. Browser tools excel at interactive development and learning, while code-based solutions provide automation, integration with CI/CD pipelines, and the ability to test patterns against large datasets. For complex applications, automated regex testing ensures patterns work correctly across different inputs and edge cases.