> ## Documentation Index
> Fetch the complete documentation index at: https://docs.b3os.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Text Pattern Match

Match text against a pattern and extract named values from it. Useful for parsing dates, addresses, URLs, and structured text. Uses Go RE2 regex syntax.

Built-in action Built In

Match text against a pattern and extract named values from it. Useful for parsing dates, addresses, URLs, and structured text. Uses Go RE2 regex syntax.


## At a Glance

| Field | Value |
| --- | --- |
| Action ID | `regex` |
| Category | Built In |
| Connector | Not required |
| Requires gas | No |
| Funds movement | None declared |
| Tags | `utility`, `regex`, `parsing`, `text`, `extraction`, `data-processing` |

## Payload Schema

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `text` | `string` | Yes | The text to match against the regex pattern. Supports workflow variables like &#123;&#123;node.result.field&#125;&#125;. |
| `pattern` | `string` | Yes | Regular expression pattern \(Go RE2 syntax\). Use \(?P&lt;name&gt;...\) for named capture groups. Max 1024 characters. |
| `global` | `boolean` | No | If true, find all matches instead of just the first. Default: false. |

## Result Schema

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `matched` | `boolean` | Yes | Whether the pattern matched the text |
| `matches` | `object` | No | Captured groups. Single mode: object with group names as keys. Global mode: array of such objects. Each object includes key '0' for the full match. Access named groups via &#123;&#123;nodeId.result.matches.groupName&#125;&#125;. |

## Examples

**Workflow node**

```json
{
  "type": "regex",
  "payload": {
    "text": "2024-01-15T10:30:00Z",
    "pattern": "(?P<year>\\d{4})-(?P<month>\\d{2})-(?P<day>\\d{2})"
  },
  "children": []
}
```
  **Test with API**

```bash
curl -X POST "https://api.b3os.org/v1/actions/regex/test" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "inputs": {
    "text": "2024-01-15T10:30:00Z",
    "pattern": "(?P<year>\\d{4})-(?P<month>\\d{2})-(?P<day>\\d{2})"
  }
}'
```

**Use expressions for dynamic values**

Payload fields can use workflow expressions such as `{{$trigger.body.amount}}`, `{{$nodes.fetch.result.price}}`, and `{{$props.asset}}` when the value should come from a trigger, prior node, or reusable workflow prop.