Skip to content

Regex Tester

Test JavaScript regular expressions with live match highlighting, capture groups, replace preview and plain-English pattern explanations.

Regex Tester

//g
Flags:
Test string
2 matches343 chars
Matches highlighted
Hello World! My email is test@example.com and my backup is hello.world@company.co.uk. Visit https://example.com or http://docs.example.org/path?q=test for more info. Phone: (555) 123-4567 or 555.987.6543 IP: 192.168.1.1 and 10.0.0.255 Date: 2026-02-11 Colors: #ff5733, #4a90d9, #333 <div class="container"> <p>Some HTML content</p> </div>
Pattern explanation
  1. [a-zA-Z0-9._%+\-] — character set
  2. + — one or more
  3. [a-zA-Z0-9.\-] — character set
  4. + — one or more
  5. \. — literal dot
  6. [a-zA-Z] — any letter
  7. {2,} — 2 or more times
Match details
Match 1 at index 25
test@example.com
Match 2 at index 59
hello.world@company.co.uk

What this tool does

You can test a regular expression against sample text directly in the browser: type a pattern, toggle the g, i, m, s, and u flags, and every match is highlighted with its index and capture groups as you type. Matching runs locally via the JavaScript RegExp engine. Keep the g flag on — without it the tester stops after the first match.

Updated . Provided as is. Check the output before you rely on it in production.

How to use Regex Tester

  1. 1

    Enter your regex pattern

    Type a regular expression in the pattern field (e.g., `^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$` for email). Use flags (g, i, m) as needed.

  2. 2

    Input test strings to match against

    Paste or type multiple test strings in the input field. The tool will highlight all matches in real-time as you type.

  3. 3

    View matches and capture groups

    See all matches highlighted with their exact positions. If your pattern has capture groups (parentheses), see the captured values listed separately.

  4. 4

    Check regex explanation

    Read the auto-generated English explanation of what your regex does. This helps you debug patterns or learn regex syntax.

  5. 5

    Test edge cases and iterate

    Add more test strings to cover edge cases (empty strings, special chars, long text). Refine your pattern until all cases pass.

Questions and answers

What is Regex Tester?
A regular expression is a pattern for matching, extracting or replacing text. This tester runs your pattern with JavaScript's RegExp engine and the g, i, m, s and u flags, highlights every match, lists numbered and named capture groups, explains the pattern in plain English, and previews replacements.
What regex flavor does this tool support?
This tool uses JavaScript's native RegExp engine, which supports standard regex syntax including character classes, quantifiers, lookahead, lookbehind, named capture groups, and Unicode property escapes.

REST API

Base URL

https://aidevhub.io/api/regex-tester/

No authentication, fair use. Abusive traffic is throttled at the edge; responses carry no quota headers. CORS enabled. OpenAPI spec

Endpoints

GET /api/regex-tester/ Test a regex pattern
POST /api/regex-tester/ Test a regex pattern

Example

curl "https://aidevhub.io/api/regex-tester/?pattern=%5Cd%2B&text=abc+123+def+456&flags=g"

Example Response

{
  "valid": true,
  "pattern": "\\d+",
  "matches": [
    {
      "match": "123",
      "index": 4
    }
  ],
  "match_count": 2
}
For AI agents: how to call this tool

Machine-readable contract, endpoints and examples. Humans can ignore this section.

Best Path For Builders

Dedicated API endpoint

Deterministic outputs, machine-safe contracts, and production-ready examples.

Dedicated API

https://aidevhub.io/api/regex-tester/

OpenAPI: https://aidevhub.io/api/openapi.yaml

GET /api/regex-tester/ Test a regex pattern
POST /api/regex-tester/ Test a regex pattern

How do I test a regex pattern against a string online?

Enter the pattern between the two slashes, pick your flags, and paste the text to search into the test string box. Matches highlight immediately, and the details panel lists each match with its character index plus any numbered or named capture groups. The engine is your browser's own JavaScript RegExp, so behavior matches what you will see in Node.js or front-end code.

Step by step

  1. Type the pattern without surrounding slashes — the tester adds the /.../ delimiters for you.
  2. Toggle flags: keep g on to find every match instead of stopping at the first.
  3. Paste your test text. Each match is highlighted in a distinct color, with index and capture groups in the side panel.
  4. Need a starting point? The Patterns menu inserts presets for emails, URLs, IPv4 addresses, ISO dates, hex colors, and more.
  5. Enable Replace mode to preview substitutions — $1, $2, and $& backreferences are supported.
  6. Copy the matched strings out with the Copy Matches button when you are done.

Test a regex from the command line (dedicated API)

The same matcher is exposed as a REST endpoint, so scripts and agents can test patterns without a browser:

curl "https://aidevhub.io/api/regex-tester/?pattern=%5Cd%2B&text=abc+123+def+456&flags=g"

The response reports validity, the pattern, each match with its index, and a match count — for example {"valid": true, "pattern": "\\d+", "matches": [{"match": "123", "index": 4}], "match_count": 2}. GET and POST are both accepted.

Which regex flags does this tester support?

Flag Name Effect
g global Find all matches instead of stopping after the first.
i case-insensitive Ignore letter case: /abc/i matches ABC, Abc, abc.
m multiline ^ and $ match at every line break, not just start and end of input.
s dotAll . also matches newline characters.
u unicode Treat the pattern as Unicode code points; enables \u{...} escapes.

Flags as implemented in this tester's UI (JavaScript RegExp semantics). The sticky (y) and hasIndices (d) flags are not exposed here.

Why does my regex only find one match?

Almost always a missing g flag. Without it, a JavaScript regex returns only the first match — the same code pasted into String.replace will then replace only one occurrence. The tester mirrors that behavior so what you see here is what your code will do.

Is it safe to paste production data into this tester?

The in-browser tester never transmits your pattern or test text; matching runs entirely in the page. Log lines and payloads you paste stay on your machine and are discarded when you close the tab. Only the optional REST API sends data to a server — use the browser tool when the text is sensitive.