Skip to main content
Glama

regex_extract

Extract matching patterns from text using regular expressions. Returns a JSON array of matches with full match and capture groups.

Instructions

Run a regular expression against text and return all matches. Supports capture groups, named groups, and multiline input. Returns a JSON array of match objects — each has match (full match) and groups (array or object for named groups). Returns an empty array if no matches are found. Returns an error if the pattern is not a valid regular expression. Has no side effects. Free. Use for extracting emails, URLs, codes, patterns, or any structured data from unstructured text.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text to search.
flagsNoRegex flags string (default "gi"). Common: g=global, i=case-insensitive, m=multiline, s=dotAll.
patternYesRegular expression pattern (without delimiters).
maxMatchesNoMax matches to return (default 100, max 500).
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It discloses no side effects, free status, error handling (invalid pattern returns error), and return format. It does not explicitly mention the maxMatches limit (default 100, max 500) from the schema, but the return behavior for no matches is stated.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is moderately concise, front-loaded with the main purpose, and well-structured. It covers key points in a few sentences but includes some redundancy (e.g., 'supports capture groups, named groups' repeated in different ways).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, but the description explains the return format (JSON array with match and groups objects). It covers I/O (text, pattern, flags, maxMatches), return values, errors, and side effects. For a tool with 4 parameters, this is fairly complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% (all 4 parameters have descriptions). The description adds value by explaining: pattern without delimiters, flags default 'gi' with common options, maxMatches defaults and limit. This goes beyond the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's action: 'Run a regular expression against text and return all matches.' It specifies the resource (text) and the verb (extract using regex). The use cases listed (extracting emails, URLs, codes) help distinguish it from sibling tools like text stats or json_query.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit guidance on when to use: 'for extracting emails, URLs, codes, patterns, or any structured data from unstructured text.' It does not explicitly state when not to use or mention alternatives, but the context is clear enough for an agent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/icosaedro-git/toolsnap-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server