Regex Utilities

Extract Groups

Extracts named and numbered capture groups from regex pattern matches. Use via MCP in Cursor or Windsurf, or call GET /v1/regex/groups with your text, pattern, and optional flags. Returns structured JSON with group names, values, and positions. Perfect for parsing structured data like emails, URLs, or log entries where you need specific parts extracted.

API Endpoint

GET /v1/regex/groups

Code Examples

curl "https://tinyfn.io/v1/regex/groups" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/regex/groups', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/regex/groups',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's regex tools:

{
  "mcpServers": {
    "tinyfn-regex": {
      "url": "https://tinyfn.io/mcp/regex",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I extract named capture groups from a regex match?

Use named groups like (?P<name>pattern) in your regex. The tool returns both named groups and their numbered equivalents in the response JSON.

What's the difference between numbered and named capture groups?

Numbered groups use parentheses (pattern) and are indexed starting at 1. Named groups use (?P<name>pattern) syntax and can be accessed by name or number.

Can I extract multiple matches or just the first one?

This tool extracts groups from the first match only. For multiple matches across a text, you'd need to call it multiple times or use a global search tool first.

How do MCP clients like Claude Code handle the group extraction results?

MCP clients receive structured JSON with group names, values, start/end positions, making it easy for AI agents to parse and use the extracted data in code generation.

What happens if my regex pattern has no capture groups?

The tool returns an empty groups object. Only parenthesized expressions create capture groups—the overall match isn't considered a group.

Try Extract Groups Now

Get your free API key and start using Extract Groups in seconds.

Get Free API Key