# Regex Tester API

> Regex Tester tests regular expressions against input strings across operations like match, search, replace, and split. It reports compilation validity, syntax error details, execution timing, and structural pattern analysis.

**Endpoint:** `POST https://api.apiverve.com/v1/regextester`  
**Category:** Text Processing  
**Cost:** 1 credit per call  
**Canonical page:** https://apiverve.com/marketplace/regextester

## Overview

A regex tester API for testing regular expressions against text from code, pipelines and no-code tools. Send a pattern, some text and optional flags, and Regex Tester runs the operation you pick (test, match, search, replace or split) and returns the result together with pattern analysis, optimization suggestions and common pattern examples you can compare against.

It is useful wherever a regular expression comes from a user or a config file rather than from your own code: validating a regex a customer typed into a filter rule, checking that a redaction pattern catches every SSN before it runs in production, previewing a find-and-replace, or teaching regex in a course or internal tool. Invalid patterns are not an error: you get the syntax message back with hints on what to fix.

The Free plan returns the operation result, compiled flag details, complexity rating, pattern analysis, suggestions and the reference library of patterns. Paid plans add performance metrics from timing the pattern over repeated runs.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/regextester" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pattern":"\\d{3}-\\d{2}-\\d{4}","text":"My SSN is 123-45-6789 and my friend'\''s is 987-65-4321","flags":"g","test_type":"value","replacement":"value"}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `pattern` | string | Yes | The regular expression pattern to test. Maximum 500 characters. length 0-500 |
| `text` | string | Yes | The text to test the pattern against. Maximum 20000 characters. length 0-20000 |
| `flags` | string | No | Regex flags: g (global), i (case insensitive), m (multiline), s (dotall), u (unicode), y (sticky) |
| `test_type` | string | No | Operation type. default test. One of: test, match, search, replace, split |
| `replacement` | string | No | Replacement text for 'replace' operation |

## Response fields

- `pattern` — string · The regular expression pattern that was tested
- `text` — string · The input text the pattern was tested against
- `flags` — string · The regex flags that were applied (g, i, m, s, u, y)
- `test_type` — string · The operation that was run: test, match, search, replace, or split
- `replacement` — object · The replacement text supplied for a replace operation, or null when not applicable
- `is_valid_regex` — boolean · Whether the supplied pattern compiled into a valid regular expression
- `regex_info` — object · Details about the compiled regex, including its flags, source, and a computed complexity rating
  - `regex_info.pattern` — string · The regular expression pattern that was tested
  - `regex_info.flags` — object · The regex flags that were applied (g, i, m, s, u, y)
    - `regex_info.flags.global` — boolean
    - `regex_info.flags.ignore_case` — boolean
    - `regex_info.flags.multiline` — boolean
    - `regex_info.flags.sticky` — boolean
    - `regex_info.flags.unicode` — boolean
    - `regex_info.flags.dot_all` — boolean
  - `regex_info.source` — string
  - `regex_info.last_index` — number
  - `regex_info.pattern_length` — number
  - `regex_info.complexity` — string
- `test_results` — object · The result of the requested operation. Its shape depends on test_type; the fields below are those returned for the default test operation.
  - `test_results.operation` — string · The operation that was actually run against the text
  - `test_results.result` — boolean · Whether the pattern matched anywhere in the text; returned when test_type is 'test'
  - `test_results.execution_time_ms` — number · How long the regex operation took to execute, in milliseconds
  - `test_results.description` — string · Human-readable explanation of what the operation's result means
- `performance` — object · Performance metrics from re-running the pattern many times to measure its average execution speed · (premium)
  - `performance.iterations` — number · (premium)
  - `performance.total_time_ms` — number · (premium)
  - `performance.average_time_ms` — number · (premium)
  - `performance.performance_rating` — string · (premium)
- `pattern_analysis` — object · Structural analysis of the pattern: which anchors, quantifiers, groups, character classes, and special characters it uses
  - `pattern_analysis.contains_anchors` — object
    - `pattern_analysis.contains_anchors.start_anchor` — boolean
    - `pattern_analysis.contains_anchors.end_anchor` — boolean
    - `pattern_analysis.contains_anchors.word_boundary` — boolean
  - `pattern_analysis.contains_quantifiers` — object
    - `pattern_analysis.contains_quantifiers.zero_or_more` — boolean
    - `pattern_analysis.contains_quantifiers.one_or_more` — boolean
    - `pattern_analysis.contains_quantifiers.zero_or_one` — boolean
    - `pattern_analysis.contains_quantifiers.specific_count` — boolean
    - `pattern_analysis.contains_quantifiers.range_count` — boolean
  - `pattern_analysis.contains_groups` — object
    - `pattern_analysis.contains_groups.capturing_groups` — number
    - `pattern_analysis.contains_groups.non_capturing_groups` — number
    - `pattern_analysis.contains_groups.named_groups` — number
  - `pattern_analysis.contains_character_classes` — object
    - `pattern_analysis.contains_character_classes.predefined_classes` — boolean
    - `pattern_analysis.contains_character_classes.custom_classes` — boolean
    - `pattern_analysis.contains_character_classes.negated_classes` — boolean
  - `pattern_analysis.contains_special_chars` — object
    - `pattern_analysis.contains_special_chars.wildcard` — boolean
    - `pattern_analysis.contains_special_chars.pipe` — boolean
    - `pattern_analysis.contains_special_chars.escape_sequences` — number
- `suggestions` — array · Suggestions for fixing an invalid pattern, or optimization tips for a valid one
  - `common_patterns.0.name` — string · Name of the ready-made pattern, for example "Email Address".
  - `common_patterns.0.pattern` — string · The regular expression source for the ready-made pattern.
  - `common_patterns.0.description` — string · What the ready-made pattern matches.
  - `common_patterns.0.example` — string · An example string the ready-made pattern matches.
- `regex_guide` — object · Reference guide to regex syntax covering basic syntax, character classes, quantifiers, groups, and flags
    - `regex_guide.basic_syntax.0.symbol` — string
    - `regex_guide.basic_syntax.0.description` — string
    - `regex_guide.character_classes.0.symbol` — string
    - `regex_guide.character_classes.0.description` — string
    - `regex_guide.quantifiers.0.symbol` — string
    - `regex_guide.quantifiers.0.description` — string
    - `regex_guide.groups.0.symbol` — string
    - `regex_guide.groups.0.description` — string
    - `regex_guide.flags.0.flag` — string
    - `regex_guide.flags.0.description` — string

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "pattern": "\\d{3}-\\d{2}-\\d{4}",
    "text": "My SSN is 123-45-6789 and my friend's is 987-65-4321",
    "flags": "g",
    "test_type": "test",
    "replacement": null,
    "is_valid_regex": true,
    "regex_info": {
      "pattern": "\\d{3}-\\d{2}-\\d{4}",
      "flags": {
        "global": true,
        "ignore_case": false,
        "multiline": false,
        "sticky": false,
        "unicode": false,
        "dot_all": false
      },
      "source": "\\d{3}-\\d{2}-\\d{4}",
      "last_index": 21,
      "pattern_length": 17,
      "complexity": "Medium"
    },
    "test_results": {
      "operation": "test",
      "result": true,
      "execution_time_ms": 0,
      "description": "Returns true if pattern matches anywhere in text, false otherwise"
    },
    "performance": {
      "iterations": 192,
      "total_time_ms": 0,
      "average_time_ms": 0,
      "performance_rating": "Excellent"
    },
    "pattern_analysis": {
      "contains_anchors": {
        "start_anchor": false,
        "end_anchor": false,
        "word_boundary": false
      },
      "contains_quantifiers": {
        "zero_or_more": false,
        "one_or_more": false,
        "zero_or_one": false,
        "specific_count": true,
        "range_count": false
      },
      "contains_groups": {
        "capturing_groups": 0,
        "non_capturing_groups": 0,
        "named_groups": 0
      },
      "contains_character_classes": {
        "predefined_classes": true,
        "custom_classes": false,
        "negated_classes": false
      },
      "contains_special_chars": {
        "wildcard": false,
        "pipe": false,
        "escape_sequences": 3
      }
    },
    "suggestions": [
      "Consider anchoring with ^ or $ if you need exact matches"
    ],
    "common_patterns": [
      {
        "name": "Email Address",
        "pattern": "^[\\w\\.-]+@[\\w\\.-]+\\.[a-zA-Z]{2,}$",
        "description": "Matches valid email addresses",
        "example": "user@example.com"
      },
      {
        "name": "Phone Number (US)",
        "pattern": "^\\(?(\\d{3})\\)?[-.\\s]?(\\d{3})[-.\\s]?(\\d{4})$",
        "description": "Matches US phone numbers in various formats",
        "example": "(123) 456-7890"
      },
      {
        "name": "URL",
        "pattern": "^https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)$",
        "description": "Matches HTTP and HTTPS URLs",
        "example": "https://www.example.com"
      },
      {
        "name": "IP Address (IPv4)",
        "pattern": "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$",
        "description": "Matches valid IPv4 addresses",
        "example": "192.168.1.1"
      },
      {
        "name": "Credit Card Number",
        "pattern": "^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3[0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})$",
        "description": "Matches major credit card formats",
        "example": "4532123456789012"
      },
      {
        "name": "Social Security Number",
        "pattern": "^\\d{3}-?\\d{2}-?\\d{4}$",
        "description": "Matches SSN with or without dashes",
        "example": "123-45-6789"
      },
      {
        "name": "Date (MM/DD/YYYY)",
        "pattern": "^(0[1-9]|1[0-2])\\/(0[1-9]|[12][0-9]|3[01])\\/(19|20)\\d{2}$",
        "description": "Matches MM/DD/YYYY date format",
        "example": "12/31/2023"
      },
      {
        "name": "Time (24-hour)",
        "pattern": "^([01]?[0-9]|2[0-3]):[0-5][0-9]$",
        "description": "Matches 24-hour time format",
        "example": "14:30"
      },
      {
        "name": "Hexadecimal Color",
        "pattern": "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$",
        "description": "Matches hex color codes",
        "example": "#FF5733"
      },
      {
        "name": "Strong Password",
        "pattern": "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$",
        "description": "At least 8 chars with uppercase, lowercase, digit, and special char",
        "example": "MyP@ssw0rd"
      }
    ],
    "regex_guide": {
      "basic_syntax": [
        {
          "symbol": ".",
          "description": "Matches any single character except newline"
        },
        {
          "symbol": "*",
          "description": "Matches 0 or more of the preceding character"
        },
        {
          "symbol": "+",
          "description": "Matches 1 or more of the preceding character"
        },
        {
          "symbol": "?",
          "description": "Matches 0 or 1 of the preceding character"
        },
        {
          "symbol": "^",
          "description": "Matches start of string"
        },
        {
          "symbol": "$",
          "description": "Matches end of string"
        },
        {
          "symbol": "|",
          "description": "OR operator"
        },
        {
          "symbol": "\\",
          "description": "Escape character"
        }
      ],
      "character_classes": [
        {
          "symbol": "[abc]",
          "description": "Matches any character in the set"
        },
        {
          "symbol": "[^abc]",
          "description": "Matches any character NOT in the set"
        },
        {
          "symbol": "[a-z]",
          "description": "Matches any lowercase letter"
        },
        {
          "symbol": "[A-Z]",
          "description": "Matches any uppercase letter"
        },
        {
          "symbol": "[0-9]",
          "description": "Matches any digit"
        },
        {
          "symbol": "\\d",
          "description": "Matches any digit (equivalent to [0-9])"
        },
        {
          "symbol": "\\w",
          "description": "Matches any word character [a-zA-Z0-9_]"
        },
        {
          "symbol": "\\s",
          "description": "Matches any whitespace character"
        }
      ],
      "quantifiers": [
        {
          "symbol": "{n}",
          "description": "Matches exactly n times"
        },
        {
          "symbol": "{n,}",
          "description": "Matches n or more times"
        },
        {
          "symbol": "{n,m}",
          "description": "Matches between n and m times"
        },
        {
          "symbol": "*?",
          "description": "Non-greedy: matches 0 or more (lazy)"
        },
        {
          "symbol": "+?",
          "description": "Non-greedy: matches 1 or more (lazy)"
        },
        {
          "symbol": "??",
          "description": "Non-greedy: matches 0 or 1 (lazy)"
        }
      ],
      "groups": [
        {
          "symbol": "(abc)",
          "description": "Capturing group"
        },
        {
          "symbol": "(?:abc)",
          "description": "Non-capturing group"
        },
        {
          "symbol": "(?<name>abc)",
          "description": "Named capturing group"
        },
        {
          "symbol": "(?=abc)",
          "description": "Positive lookahead"
        },
        {
          "symbol": "(?!abc)",
          "description": "Negative lookahead"
        },
        {
          "symbol": "(?<=abc)",
          "description": "Positive lookbehind"
        },
        {
          "symbol": "(?<!abc)",
          "description": "Negative lookbehind"
        }
      ],
      "flags": [
        {
          "flag": "g",
          "description": "Global - find all matches"
        },
        {
          "flag": "i",
          "description": "Case insensitive"
        },
        {
          "flag": "m",
          "description": "Multiline - ^ and $ match line breaks"
        },
        {
          "flag": "s",
          "description": "Dot matches newline characters"
        },
        {
          "flag": "u",
          "description": "Unicode mode"
        },
        {
          "flag": "y",
          "description": "Sticky - matches from lastIndex position"
        }
      ]
    }
  }
}
```

## Use cases

- **Pattern Development** — Test and debug regex patterns before implementing them in production code to ensure correct matching
- **Data Validation** — Validate regex patterns for input validation in forms, APIs, and data processing pipelines
- **Text Processing** — Test regex patterns for text extraction, replacement, and parsing operations
- **Learning Tool** — Learn regex syntax with detailed guides, common pattern examples, and real-time testing feedback

## SDKs

- **npm** — `npm install @apiverve/regextester` (https://www.npmjs.com/package/@apiverve/regextester)
- **PyPI** — `pip install apiverve-regextester` (https://pypi.org/project/apiverve-regextester/)
- **NuGet** — `dotnet add package APIVerve.API.RegexTester` (https://www.nuget.org/packages/APIVerve.API.RegexTester)
- **Source** — https://github.com/apiverve/regextester-api

## More

- Full reference: https://docs.apiverve.com/ref/regextester
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
