Free Tool

    RegEx Tester

    Test, debug, and visualize regular expressions with real-time matching.

    Regular Expression

    //g
    Flags:
    Presets:

    Test String

    What Are Regular Expressions?

    Regular expressions (regex) are patterns used to match character combinations in strings. They are supported in virtually every programming language and are essential for text processing, input validation, search-and-replace, and log parsing.

    JavaScript Regex Flags

    • g — Global: find all matches, not just the first
    • i — Case-insensitive matching
    • m — Multiline: ^ and $ match line boundaries
    • s — Dotall: . matches newline characters

    Common Use Cases

    • Validating email addresses, phone numbers, and URLs
    • Extracting data from log files and structured text
    • Search-and-replace in code editors and IDEs
    • Building input masks and form validators
    • Parsing and transforming CSV, JSON, and XML data

    When To Reach For Regex

    Regular expressions shine for short, well-defined patterns where you need to match, extract, or replace text — log line parsing, URL routing rules, form-field validation, and search-and-replace inside an editor. They become a liability when the input is actually a structured language: HTML, JSON, source code, or anything with nested delimiters. For those, use a real parser; the regex you write today will silently break on the next edge case.

    Regex FAQ

    Quick answers to the regex questions you actually hit when writing patterns by hand.

    Which regex flavor does this tester use?
    ECMAScript / JavaScript regex (the engine built into your browser). Patterns that work here will work in `String.prototype.match`, `RegExp.test`, and most modern JS-based linters or editor extensions. Patterns written for PCRE (PHP, Perl), Python's `re`, or Go's `regexp` may behave differently — lookbehinds, atomic groups, and named-group syntax are common divergence points.
    How do I make my pattern case-insensitive?
    Toggle the `i` flag (Case-Insensitive). It applies the case fold across the whole pattern, so `/Hello/i` matches `hello`, `HELLO`, and `HeLLo`. If you only want one part of the pattern to be case-insensitive, you have to enumerate characters explicitly — JavaScript regex doesn't support inline mode modifiers like `(?i:...)`.
    Why doesn't my regex match across multiple lines?
    Two flags affect multi-line behaviour. The `m` (Multiline) flag changes `^` and `$` so they match at line boundaries instead of only the start/end of the whole string — useful for line-by-line validation. Separately, the `s` (dotAll) flag makes `.` match newlines too — without it, `.*` stops at the first `\n`. Most multi-line use cases need both.
    What's the difference between greedy and lazy quantifiers?
    By default quantifiers like `*`, `+`, and `{n,m}` are greedy — they consume as much input as possible while still allowing the overall match to succeed. Appending `?` makes them lazy: they consume the minimum and let later parts of the pattern grab the rest. Greedy `<.+>` against `` matches the whole string; lazy `<.+?>` matches just ``. Lazy quantifiers are usually what you want when extracting fields between delimiters.
    How do I escape special characters in my pattern?
    Why does my regex match more (or less) than expected?