Regex Tester & Validator

Test and validate regular expression patterns against target text with real-time match extraction, group captures, and ReDoS safety analysis.

Flags:
/ /g

How to Use the Regex Tester & Validator

1

Enter Regular Expression

Type your regular expression pattern in the input box and toggle necessary flags (g, i, m).

2

Paste Target Text

Enter or paste the string you want to validate and test against.

3

Review Match Table

Click Test & Validate Regex to view extracted matches, character index offsets, and capture groups in a structured UI table.

Tool Options

Real-time Match Validation

Instant evaluation with zero server latency, verifying expressions directly against sample test strings.

ReDoS Safety Analyzer

Analyzes regex structure for catastrophic backtracking risks and nested quantifiers before execution.

Structured UI Output

Displays matches, character offsets, and sub-groups in clean visual cards with 1-click clipboard copying.

Your Data Privacy

Web Tool
Privacy-First Architecture
Most of our web tools process your data entirely in-browser. Where server processing is technically required, payloads are evaluated statelessly in-memory and are never stored, saved, or logged.
REST API
Stateless In-Memory Processing
When you use our API endpoints, your requests are processed strictly in-memory without persistent database storage, disk logging, or data retention.
Want to learn more about how we safeguard your information and infrastructure?
Read our full Privacy Policy for detailed security standards, data retention principles, and compliance guarantees.

What does the Regex Tester & Validator do?

The Regex Tester & Validator compiles, validates, and tests regular expression (regex) patterns against arbitrary text in real time. It calculates full match indices, extracts numbered and named capture groups, supports standard flags (g, i, m, s), and performs ReDoS safety vulnerability checks.

Core Concepts

  • Global Matching (g): Scans through the entire document to capture all matches rather than halting at the first match.
  • Case-Insensitive Matching (i): Matches upper and lowercase characters identically without requiring explicit range duplication ([a-zA-Z]).
  • Multiline Anchors (m): Changes ^ and $ from matching document start/end to matching the beginning and end of each individual line.
  • DotAll Matching (s): Allows the . wildcard to match newline characters (\n, \r).
  • Capture Groups & Named Groups: Parentheses (...) capture sub-patterns into numbered indices, while (?<name>...) extracts named dictionary properties.

How to use the tool?

  1. Enter Pattern or Select Preset: Type your regex pattern into the expression input or select a preset from the master toolbar (Email, IPv4, UUID, URL, ISO Date, JWT, API Key).
  2. Toggle Flags & Input Text: Set active flags (g, i, m, s) and type or paste your target test string.
  3. Instant Real-Time Inspection: Extracted matches, offset character indices, capture groups, and ReDoS safety warnings update instantly on every keystroke.
  4. Export & Download: Click Copy to copy the complete match report to your clipboard or Download to save it as a text file.

Related Developer Utilities

If you are working with text processing, pattern matching, and data validation, explore these related tools:

REST API Integration

blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/regex/tester) to programmatically test, validate, and extract capture groups using JavaScript-compatible regular expressions.

API Request Parameters

Name Type Description Example
pattern String / Object Regular expression pattern string or payload object (aliases: regex, rawText, expression). "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}"
text String Target text string to evaluate against the regex pattern (aliases: input, target, string). "Contact support@blueutils.com for help."
flags String Flag modifiers ("g", "i", "m", "s"). Defaults to "g". "g"

API Request Payload Examples

cURL

curl -X POST https://blueutils.com/api/regex/tester \
  -H "Content-Type: application/json" \
  -d '{
    "pattern": "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}",
    "text": "Contact support@blueutils.com or dev@blueutils.com for help.",
    "flags": "g"
  }'

Python

import requests

url = "https://blueutils.com/api/regex/tester"
payload = {
    "pattern": r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b",
    "text": "Server IP is 10.0.0.1 and Gateway is 10.0.0.254",
    "flags": "g"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String jsonPayload = """
            {
                "pattern": "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,}",
                "text": "Contact support@blueutils.com for help.",
                "flags": "g"
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://blueutils.com/api/regex/tester"))
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

API Response Parameters

Name Type Description Example
isValid Boolean Returns true if the regex compiled and executed successfully. true
pattern String Echoes the validated regex pattern. "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}"
flags String Active flag modifiers used. "g"
matchCount Number Total count of pattern matches identified in text. 2
isMatch Boolean Returns true if at least one match was found. true
matches Array Array of match objects detailing match string, index position, and captured groups. [...]

API Response Payload Examples

Success Response (HTTP 200 OK)

{
  "isValid": true,
  "pattern": "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}",
  "flags": "g",
  "matchCount": 2,
  "isMatch": true,
  "matches": [
    {
      "match": "support@blueutils.com",
      "index": 8,
      "groups": []
    },
    {
      "match": "dev@blueutils.com",
      "index": 33,
      "groups": []
    }
  ]
}

Validation Failure Response (HTTP 400 Bad Request)

{
  "isValid": false,
  "error": "Regex Compilation Error: Invalid regular expression: /[a-z/: Unterminated character class"
}

Rate Limit Exceeded Response (HTTP 429 Too Many Requests)

{
  "error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}

Why use an API to test regular expressions?

Integrating the Regex Tester API into automated test suites, input validation services, or CI/CD pipelines provides several advantages:

  • Rapid Script Validation: Enables developers to dynamically test user-submitted regex filters against sample datasets without deploying backend changes.
  • Optimized Token Efficiency for AI Agents: LLMs often hallucinate regex match indices or fail complex lookarounds. Invoking the API provides exact match offsets and capture groups with zero reasoning token overhead.
  • Deterministic Accuracy Without Hallucinations: Ensures 100% deterministic pattern execution adhering strictly to ECMAScript RegExp specifications.

Native Usage

How to test regular expressions locally using command-line utilities and scripts:

Windows (CMD / PowerShell)

# Match regular expression patterns in PowerShell
Select-String -Path .\logfile.txt -Pattern "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}"

Linux / Unix (Bash)

# Using grep with extended regular expressions (ERE)
grep -E -o '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' server.log

Python

Using Python standard library re:

import re

pattern = r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}"
text = "Contact support@blueutils.com or dev@blueutils.com for help."

matches = re.finditer(pattern, text)
for m in matches:
    print(f"Match: '{m.group()}' at index {m.start()}-{m.end()}")

Java

Using java.util.regex.Pattern and Matcher:

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexTesterExample {
    public static void main(String[] args) {
        String regex = "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}";
        String text = "Contact support@blueutils.com or dev@blueutils.com for help.";

        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);

        while (matcher.find()) {
            System.out.println("Found match: " + matcher.group() + " at index " + matcher.start());
        }
    }
}

Frequently Asked Questions (FAQ)

How does the Regex Tester evaluate regular expressions in real time?

As you type or modify your regex pattern, the tool compiles a native RegExp instance in-browser, executes global or single match scanning against your target text, and displays extracted substrings, character offsets, and capture groups with zero latency.

What is the difference between global (g), case-insensitive (i), multiline (m), and dotAll (s) flags?

The g flag finds all matching occurrences across the entire text, i ignores upper/lowercase character differences, m treats ^ and $ as matching line beginnings and endings rather than the whole string, and s allows the dot . wildcard to match newline characters.

How does the ReDoS Safety Analyzer detect catastrophic backtracking?

The analyzer inspects your regular expression for nested quantifiers (such as (a+)+ or ([a-z]*)*) and overlapping alternations that can cause exponential execution time and browser freezes when evaluating non-matching input strings.

Does the tester support named capture groups and group indexing?

Yes. Both numbered capture groups (...) and ES2018 named capture groups (?<name>...) are automatically parsed, extracted, and displayed inside dedicated match cards alongside full-match character index offsets.

Are my sensitive test strings, API keys, or tokens sent to external servers?

No. All regular expression compilation, pattern matching, group extraction, and ReDoS safety analysis execute 100% locally in your browser without transmitting your data to remote servers.

Rate Limits

UI Limits
100 uses per 15 minutes
Max payload size: 5 MB
API Limits
5 requests per 60 minutes
Max payload size: 256 KB
Need higher API rate limits, increased payload sizes, or custom developer solutions?
Contact our engineering team at support@blueutils.com for custom rate limit increases, higher quota allocations, or tailored enterprise integrations.