UltraConvert
Text Tools

Regex Tester

Develop and debug regular expressions with live testing against your sample text. Visual match highlighting shows exactly what matches. Inspect capture groups, test replacement strings, and toggle all JavaScript regex flags. A 200ms execution timeout prevents runaway patterns from freezing your browser.

What does this tool do?

The Regex Tester provides an interactive environment for developing JavaScript regular expressions. It offers live match highlighting in the test text, detailed inspection of capture groups (both numbered $1, $2 and named groups), all JavaScript regex flags (g global, i ignore case, m multiline, s dotAll, u unicode, y sticky), and a replacement mode to test regex substitutions with $1, $2 references. The interface catches common regex errors and prevents catastrophic backtracking with a 200ms timeout per execution.

How it works

The tool constructs a JavaScript RegExp object from your pattern string and selected flags. For matching, it uses RegExp.prototype.exec() in a loop for global matches or single execution for non-global. Matches are highlighted by calculating character positions in the text. Capture groups are extracted from the match array (index 0 is full match, 1+ are groups). For replacement, String.prototype.replace() is used with your replacement string that can reference $& (full match), $1-$99 (capture groups), $` (before match), $' (after match). A setTimeout-based watchdog interrupts execution if it exceeds 200ms, protecting against ReDoS (Regular Expression Denial of Service) patterns.

Features

How to use

  1. 1

    Enter your pattern

    Type the regex pattern without leading/trailing slashes — just the pattern body. Use standard JavaScript regex syntax.

  2. 2

    Toggle flags as needed

    g for global (find all matches), i for case-insensitive, m for ^/$ matching line start/end, s for dot matching newlines, u for Unicode, y for sticky matching.

  3. 3

    Paste test text

    Enter sample text that should match (and some that shouldn't). Matches highlight live as you edit. Click any match for details.

  4. 4

    Review matches and groups

    Each match shows the full text, position, and all capture groups. Use this to verify your pattern extracts the right data.

  5. 5

    Test replacement (optional)

    Switch to Replace mode to test substitution patterns. Use $1, $2 for capture group references, $& for full match.

Common use cases

Pattern development

Build and refine regex patterns for data validation, parsing, extraction, and text processing before adding to code.

Debugging regex issues

When a regex in your code behaves unexpectedly, paste it here with sample data to isolate the problem.

Data extraction planning

Develop patterns for log parsing, web scraping, or data cleaning by testing against real sample data.

Replacement strategy testing

Test find-and-replace patterns with capture groups before applying to large datasets or production code.

Tips & best practices

Frequently asked questions

Does it support PCRE-only features?
It uses JavaScript's RegExp. Modern browsers support ES2018+ features: lookbehinds (?<=...), named groups (?<name>...), and Unicode property escapes \p{...}. These work in current browsers.
What about regex injection if I paste untrusted patterns?
The 200ms timeout per match attempt prevents catastrophic backtracking attacks (ReDoS). Patterns that would run forever are interrupted safely.
Why does my pattern match differently than in Python/PHP/Java?
Different languages have slightly different regex flavors. JavaScript lacks some features (atomic groups, possessive quantifiers) and has slightly different behavior for some edge cases. This tool shows JavaScript behavior.
Can I save or share my regex?
Currently patterns aren't savable in the tool. Copy the pattern and flags manually to share or save. URL-based sharing is on the roadmap.

Related tools