# Match Text

<!-- meta: type=match-regex; location=Logic; category=Logic; platforms=Joomla and WordPress (where applicable) -->

## Overview

Match Text is a **Logic** in **Logic**. Matches or replaces text using presets, simple phrases, or a custom pattern.

This step executes when the flow reaches it along a wired path. It does not call external services by itself unless combined with API or CMS steps — it shapes *how* the flow continues.

## Why use this node

Match Text is a **logic step** in the **Logic** group. Logic steps control how data moves through the flow: branch on conditions, loop over lists, pause, merge parallel paths, or reshape payloads.

Typical reasons teams add **Match Text** to a flow:

- Control flow structure around match text in complex multi-step workflows
- Combine with triggers and action steps to replace bespoke integration scripts
- Make branching, looping, or timing explicit and testable in the designer

## Example workflows

Common patterns on the canvas:

1. **Trigger** → **Match Text** → **Send Email** / **API REST POST**
2. Parallel branches → **Merge** → **Match Text** → downstream action

## How to set it up

Optional replace mode writes the result to a payload field you name.

## Good to know

Prefer presets when possible — easier to read in the designer than raw regex.

## Properties panel

The designer shows these tabs for this node:

| Tab | Purpose |
|-----|---------|
| **Info** | Plain-language description and output payload fields for downstream steps |
| **General** | Canvas label and read-only node ID |
| **AI** | Optional assistant to help draft settings from plain language |
| **Design** | Node-specific configuration fields |

### System (automatic — not edited by the user)

These fields are managed by the designer or runtime — you do not type into them directly:

| Property key | Label | Type | Required | Visible when | Notes |
|--------------|-------|------|----------|--------------|-------|
| `_nodeId` | Node ID | `node-id` | No | — | — |
| `_payloadFields` | Available Fields | `payload-panel` | No | — | — |

### User-configured — General tab

| Property key | Label | Type | Required | Visible when | Notes |
|--------------|-------|------|----------|--------------|-------|
| `label` | Label | `text` | No | — | Node label |

### User-configured — Design tab

| Property key | Label | Type | Required | Visible when | Notes |
|--------------|-------|------|----------|--------------|-------|
| `patternStyle` | How to match | `select` (`preset` \| `simple` \| `custom`) | No | — | Common pattern — built-in regex presets (email, URL, …).

Find exact words — literal phrase: choose contains / starts with / ends with / equals. No {{}} in the phrase unless you want those characters literally.

Custom pattern — PCRE pattern body only; delimiters are added at runtime. |
| `matchText` | Text to search in | `payload-text` | No | — | Leave empty to use the whole incoming payload as JSON text, or drag a field / use {{node_id.field}} Leave empty to run the match on the full incoming payload serialized as text (JSON).

Otherwise: same rules as other payload fields — literals plus {{node_id.field}} from upstream, or drag chips from Available Payload Fields. |
| `presetPattern` | Common pattern | `select` (`email` \| `url` \| `phone_us` \| `digits` \| `letters` \| `word` \| `uuid` \| `postal_us`; default: `email`) | No | `matchRegexShowPreset` | Pick which built-in pattern to search for inside the text to search in. No manual regex here — switch to “Custom pattern” for your own PCRE body. |
| `simpleMatch` | Phrase should… | `select` (`contains` \| `starts_with` \| `ends_with` \| `equals`; default: `contains`) | No | `matchRegexShowSimple` | How the phrase in “Text to find” is compared: substring, prefix, suffix, or whole-string equality. Matching still respects “Ignore uppercase/lowercase” when that toggle is on. |
| `simplePhrase` | Text to find | `text` | No | `matchRegexShowSimple` | Type the words to look for (no special syntax) Plain characters only for this mode — not a regex and not {{placeholders}}. Use “Text to search in” if you need dynamic source text from the payload. |
| `customPattern` | Custom pattern | `textarea` | No | `matchRegexShowCustom` | PCRE body only (delimiters added for you). Markdown bold spans: \*\*(.*?)\*\* — use ? so each **…** matches separately. Turn on “Find every occurrence” to replace all of them. Enter the regex body only (no leading / delimiters). The runtime wraps it as a PCRE pattern.

Use capturing groups () if you need $1, $2 in “Replace with”. Non-greedy quantifiers (? instead of *) help when you replace multiple occurrences.

Example for bold markdown chunks: \*\*(.*?)\*\* — turn on “Find every occurrence” to replace each **…** separately. |
| `caseInsensitive` | Ignore uppercase/lowercase | `toggle` (default: `true`) | No | — | When on, matching uses case-insensitive mode (/i). When off, letter case must match exactly. |
| `findAll` | Find every occurrence (not just the first) | `toggle` (default: `false`) | No | — | When off, only the first match is considered (and replaced if replace is on). When on, every non-overlapping match is found; use with replace to rewrite all occurrences. |
| `replaceEnabled` | Replace matched text | `toggle` (default: `false`) | No | — | When on, each match is replaced using “Replace with” (after resolving {{}} there). When off, text is not rewritten; use this to only detect patterns or to preview before replacing. |
| `replacementText` | Replace with | `payload-text` | No | — | Plain text, or $1 $2 for capture groups (advanced). Leave empty to remove matches. Literal text and/or capture backreferences: $1, $2 for groups from the pattern.

{{placeholders}} are resolved from the payload before substitution. Leave empty to delete matched text.

Turn on “Replace matched text” for this field to take effect. |
| `outputFieldKey` | Output field name | `text` (default: `replaced_text`) | No | — | replaced_text Name of the string property added on the outgoing payload (default replaced_text). Use letters, digits, and underscores; avoid spaces. Downstream nodes read this key. |

### CMS site configuration (not on this node's properties panel)

Credentials, API keys, mailers, SMTP, and integration defaults are configured in the CMS plugin under **Node Configuration**, not per step on this node. Link the flow to a domain before testing CMS-backed fields.

## Output payload fields

After this step runs, later nodes can reference these fields using placeholders such as
`{{match_text.regex_matched}}`.

| Field key | Type | Description |
|-----------|------|-------------|
| `regex_matched` | boolean | Whether the regex found a match. |
| `regex_match` | string | First full regex match string. |
| `regex_groups` | array | Captured regex groups as an array. |
| `regex_all_matches` | array | All matches when global mode is enabled. |
| `regex_pattern_effective` | string | Pattern actually used after placeholder resolution. |
| `regex_error` | string | Regex error message, if any. |
| `replaced_text` | string | Text value from this node's output. |

## Related nodes

Other steps in the same area of the palette:

- **Array to String** (`join-array-to-text`) — Logic
- **Check Condition** (`if`) — Logic
- **Filter List** (`filter-list`) — Logic
- **Logger** (`debug`) — Logic
- **Merge** (`merge`) — Logic
