# Regex API
> Run regular expressions server-side without the ReDoS risk. Test whether a pattern matches, extract all matches with their positions and capture groups (numbered and named), replace with a substitution pattern, or split text — all with the familiar JavaScript regex flags (g, i, m, s, u, y). Every evaluation runs in an isolated sandbox with a hard timeout, so a catastrophic-backtracking pattern can never hang your service; you get a clear timeout error instead. Inputs accept GET query parameters or a JSON POST body. Pure local compute with no third-party upstream, so responses are instant and the service is always available. Ideal for no-code and automation platforms, data-cleaning pipelines, form and input validation, log parsing and content tooling.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/regex-api/..."
```

## Pricing
- **Free** (Free) — 1,000 calls/Mo, 2 req/s
- **Basic** ($4/Mo) — 50,000 calls/Mo, 8 req/s
- **Pro** ($13/Mo) — 500,000 calls/Mo, 25 req/s
- **Mega** ($29/Mo) — 3,000,000 calls/Mo, 60 req/s

## Endpoints

### Regex

#### `GET /v1/match` — Find matches + capture groups

**Parameters:**
- `pattern` (query, required, string) — Regular expression Example: `\d+`
- `text` (query, required, string) — Subject text Example: `order 42 ships 7`
- `flags` (query, optional, string) — JS flags: g i m s u y Example: `g`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/regex-api/v1/match?pattern=%5Cd%2B&text=order+42+ships+7&flags=g"
```

**Response:**
```json
{
    "data": {
        "count": 2,
        "flags": "g",
        "matches": [
            {
                "index": 6,
                "match": "42",
                "named": null,
                "groups": []
            },
            {
                "index": 15,
                "match": "7",
                "named": null,
                "groups": []
            }
        ],
        "pattern": "\\d+"
    },
    "meta": {
        "timestamp": "2026-05-30T18:17:01.082Z",
        "request_id": "1532013b-1460-4df8-9ea4-41f50dd4b301"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

#### `GET /v1/replace` — Replace matches

**Parameters:**
- `pattern` (query, required, string) — Regular expression Example: `\d+`
- `text` (query, required, string) — Subject text Example: `order 42 ships 7`
- `replacement` (query, optional, string) — Replacement (supports $1, $<name>) Example: `#`
- `flags` (query, optional, string) — JS flags: g i m s u y Example: `g`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/regex-api/v1/replace?pattern=%5Cd%2B&text=order+42+ships+7&replacement=%23&flags=g"
```

**Response:**
```json
{
    "data": {
        "flags": "g",
        "result": "order # ships #",
        "pattern": "\\d+",
        "replacement": "#"
    },
    "meta": {
        "timestamp": "2026-05-30T18:17:01.219Z",
        "request_id": "22eb8fc1-3729-4126-b4ec-3601bd74b629"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

#### `GET /v1/split` — Split text by a pattern

**Parameters:**
- `pattern` (query, required, string) — Regular expression Example: `[,;]`
- `text` (query, required, string) — Subject text Example: `a,b;c,d`
- `flags` (query, optional, string) — JS flags: g i m s u y Example: `g`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/regex-api/v1/split?pattern=%5B%2C%3B%5D&text=a%2Cb%3Bc%2Cd&flags=g"
```

**Response:**
```json
{
    "data": {
        "count": 4,
        "flags": "g",
        "parts": [
            "a",
            "b",
            "c",
            "d"
        ],
        "pattern": "[,;]"
    },
    "meta": {
        "timestamp": "2026-05-30T18:17:01.337Z",
        "request_id": "201519d1-1506-4979-96b0-d37601e4fd40"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

#### `GET /v1/test` — Test if a pattern matches

**Parameters:**
- `pattern` (query, required, string) — Regular expression Example: `\d+`
- `text` (query, required, string) — Subject text Example: `order 42 ships 7`
- `flags` (query, optional, string) — JS flags: g i m s u y Example: `g`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/regex-api/v1/test?pattern=%5Cd%2B&text=order+42+ships+7&flags=g"
```

**Response:**
```json
{
    "data": {
        "first": {
            "index": 6,
            "match": "42",
            "named": null,
            "groups": []
        },
        "flags": "g",
        "matched": true,
        "pattern": "\\d+"
    },
    "meta": {
        "timestamp": "2026-05-30T18:17:01.418Z",
        "request_id": "223a46f3-d01a-458d-93ef-f742e07c31ae"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/regex-api
OpenAPI spec: https://www.oanor.com/api/regex-api/openapi.json
