Delx
Tools / MCP Regex Tool

MCP Regex Tool

The regex tool tests regular expressions against text and returns all matches with positions and capture groups. Agents use it for text extraction, input validation, log parsing, and pattern matching. It supports JavaScript regex syntax with flags (g, i, m, s). The tool is stateless, handles inputs up to 100KB, and returns results in under 10ms.

Endpoint

POST /api/v1/utils/regex

Parameters

NameTypeRequiredDescription
patternstringYesRegular expression pattern (JavaScript syntax).
textstringYesText to match against.
flagsstringNoRegex flags: g (global), i (case-insensitive), m (multiline), s (dotall).

Examples

Extract email addresses

POST /api/v1/utils/regex {"pattern": "[\\w.+-]+@[\\w-]+\\.[\\w.]+", "text": "Contact us at support@delx.ai or sales@delx.ai", "flags": "gi"}

Finds all email addresses in the text with their positions.

Parse log entries with capture groups

POST /api/v1/utils/regex {"pattern": "\\[(\\w+)\\] (\\d{4}-\\d{2}-\\d{2}) (.+)", "text": "[ERROR] 2026-03-14 Connection timeout on /api/users"}

Capture groups extract the log level, date, and message separately for structured processing.

Use Cases

Supported regex features

The tool supports the full JavaScript regex specification: character classes, quantifiers, lookahead/lookbehind, named groups, backreferences, and Unicode escapes. Flags g, i, m, and s are supported. The tool does NOT support PCRE-only features like recursive patterns or conditional subpatterns. For most agent text processing tasks, JavaScript regex is more than sufficient.

FAQ

Is there a timeout for complex patterns?

Yes. Patterns that take longer than 100ms to execute are killed to prevent ReDoS attacks. Keep patterns simple and avoid nested quantifiers on overlapping groups.

Can I use named capture groups?

Yes. Use (?<name>pattern) syntax. Named groups appear in the response alongside indexed groups for easier processing.

What is the text size limit?

100KB. For larger texts, split into chunks. Most agent-generated text fits well within this limit.

Is it free?

Yes. Free utility tool, no API key needed, no rate limits for reasonable usage.

CLI usage?

delx utils regex "pattern" "text" --flags gi. Outputs matches as JSON lines for easy piping.