All tools

Regex Tester

Test regular expressions against sample text with real-time match highlighting.

Pattern
Test String
Highlighted Matches
Matches will be highlighted here

Your regex pattern and test text are processed entirely in your browser using the JavaScript RegExp engine. Nothing is sent to CodeAva servers and nothing is stored between sessions.

Overview

Regular expressions are a concise language for describing text patterns — useful for validation, search-and-replace, log parsing, data extraction, and input scrubbing. A regex tester lets you write a pattern and immediately see which parts of your sample text match, without needing to run a script or deploy code. Feedback is instant, which makes pattern design much faster than the edit-run-check cycle.

This tool uses the JavaScript RegExp engine, which supports most modern regex features including named capture groups, lookaheads, lookbehinds (in environments that support them), and the s (dotAll) flag. Matched segments are highlighted directly in the test string, and match details — including index positions — are listed below.

The four supported flags are g (global — find all matches), i (case insensitive), m (multiline — makes ^ and $ match line boundaries), and s (dotAll — makes . match newlines too).

Use cases

When to use it

  • Input validationtest patterns for email addresses, phone numbers, postcodes, and other field formats before wiring them into code.
  • Log parsingextract timestamps, error codes, or IP addresses from log lines with capture groups.
  • Search-and-replace planningverify a pattern matches the right strings before using it in a bulk replace operation.
  • Data extractionpull structured values from semi-structured text like API responses, CSV rows, or markdown.
  • Pattern debuggingdiagnose why an existing regex is not matching or is matching too broadly.

When it's not enough

  • Parsing complex languagesdo not use regex to parse HTML, XML, JSON, or full programming language syntax — use a dedicated parser instead.
  • Production validation in isolationtest against a representative sample set; a pattern that works on your test string may fail on edge cases in real data.
  • Security-critical filteringregex-based blocklists for user input sanitisation are fragile — pair them with a proven library for security contexts.

How to use it

  1. 1

    Enter your pattern

    Type your regular expression in the pattern field between the / delimiters. No need to add outer slashes — they are decorative.

  2. 2

    Select flags

    Toggle g, i, m, or s flags as needed. The g flag is on by default to find all matches.

  3. 3

    Paste your test string

    Add the text you want to test against in the left panel. Matching updates as you type.

  4. 4

    Review highlighted matches

    Matched segments are highlighted in the right panel. The match count and index positions appear below.

  5. 5

    Refine and iterate

    Adjust the pattern or flags and watch the highlights update immediately. Copy the finalised pattern from the input field.

Common errors and fixes

Unescaped special characters

Characters like . * + ? ( ) [ ] { } ^ $ | \ have special meaning in regex. To match them literally, escape with a backslash: \. matches a literal dot.

Pattern matches too much (greedy matching)

Quantifiers like * and + are greedy by default — they match as much as possible. Add ? to make them lazy: .*? matches as little as possible. Use anchors (^ and $) to bound the match.

No matches despite correct-looking pattern

Check flag settings. Without the i flag, matching is case-sensitive. Without the m flag, ^ and $ only match the start and end of the full string, not individual lines.

Invalid regex error on valid-looking pattern

Common causes: unmatched parentheses, unclosed character classes [ ], or invalid escape sequences. The error message from the JavaScript engine will indicate the position of the problem.

Lookbehind not working

Lookbehind assertions ((?<=...) and (?<!...)) require a modern browser or JavaScript runtime. They are supported in Chrome, Edge, Firefox, and Node.js 10+, but not in older Safari or IE environments.

Frequently asked questions