Skip to content

Regex Tester

//g
Flags:
Test String
343 chars
Match Details
Enter a pattern to start matching

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.

Last updated:

This tool is provided as-is for convenience. Output should be verified before use in any production or critical context.

Programmatic Access

Regex Tester is also callable as a free HTTP JSON API at https://aidevhub.io/api/regex-tester/ — GET with query parameters or POST with a JSON body, no authentication, CORS enabled, 50 requests/day per IP. Responses return { ok, tool, result, meta }.

curl -s "https://aidevhub.io/api/regex-tester/?pattern=%5Cd%2B&text=abc%20123%20def%20456&flags=g"

Machine-readable contract: /api/tool/regex-tester.json All API endpoints: /agents/ LLM site index: /llms.txt

Agent Invocation

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

Unified Runtime API

https://aidevhub.io/api/tools/run/?toolId=regex-tester&a=...

GET and POST are supported at /api/tools/run/ with identical validation and limits.

Limit: 10 req / 60s, input max 512 KB.

REST API

Base URL

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

50 requests/day per IP. No authentication required. 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
}

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.

Frequently Asked Questions

What is Regex Tester?
Regex Tester is a real-time regular expression testing tool with instant match highlighting and pattern explanation. It's essential for developers writing, debugging, or learning regex patterns.
How do I use Regex Tester?
Enter your regex pattern in the top field and your test string below. Matches are highlighted in real time. You can set flags like global, case-insensitive, and multiline, and view captured groups for each match.
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.

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; the free tier is rate-limited to 50 requests per day.

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.