Intermediate

Find & Replace Nodes: Pipeline Text Transformation

Transform, sanitize, and remap text flowing through your canvas with sequential replacement rules, case matching, pattern matching, and real-time preview.

# Find & Replace Nodes: Pipeline Text Transformation
### *Cleaning, standardizing, and remapping text across your visual pipeline in real time.*

As modular documents and prompt pipelines grow in complexity, you frequently need to update names, swap terminology, strip formatting tags, or anonymize private information across multiple nodes. Instead of manually editing text inside dozens of individual cards, the **Find & Replace Node** acts as an inline transformer that cleans and modifies text on the fly as it flows between your nodes.

---

## 1. Common Use Cases

The Find & Replace Node is designed for non-destructive pipeline transformations:

1. **Character & Persona Remapping**:
   - In storytelling, game writing, or roleplay prompt graphs, instantly swap character names, factions, or pronouns across an entire story outline without touching your original draft nodes.
2. **Branding & Terminology Standardization**:
   - Update draft project names, product tiers, or client names across all outgoing prompts and export documents simultaneously.
3. **Template Tag Sanitization**:
   - Strip unwanted boilerplate, clean up legacy placeholder brackets, or format raw text before piping into an AI Agent or Output Hub.
4. **Data Anonymization**:
   - Automatically redact or replace private names, email addresses, or phone numbers before exporting your documents or sharing canvas templates.

---

## 2. Ports & Multi-Branch Architecture

Like standard text nodes, the Find & Replace Node supports both combined document streams and individual branch routing:

```
[ Upstream Node 1 ] ───> [ IN (Slot 1)  ] ─── Find & Replace ───> [ All out  ] ───> [ Downstream Node ]
[ Upstream Node 2 ] ───> [ IN (Slot 2)  ]      (Rules 1, 2, 3)  ───> [ OUT (1)   ] ───> [ Alternative Branch ]
                         [ + Add Input  ]                       ───> [ OUT (2)   ]
```

1. **Main Output (`All out`)**:
   - Located at the top right of the node in prominent green.
   - Compiles and concatenates all connected input streams in top-to-bottom spatial order, applying all active replacement rules sequentially.
   - Ideal for sending your fully transformed document directly into an **Output Hub** or **Document Exporter Node**.
2. **Dynamic Input Slots (`IN`)**:
   - Accept connections from upstream Text Nodes, Prompt Cards, or Output Hubs.
   - Each input slot displays the name of its connected upstream source node.
3. **Individual Branch Outputs (`OUT`)**:
   - Each `IN` slot has a paired `OUT` port on the right edge on the same line.
   - This allows you to extract the transformed version of *only that specific input stream* without merging it with other connected nodes.
4. **Dynamic On-Demand Expansion (`+ Add Input`)**:
   - Drag a noodle from any upstream node directly to the **`+ Add Input`** handle at the bottom left to create a new input slot instantly.
5. **Slot Reordering & Removal**:
   - Hover over any input slot to reveal reordering controls (Up and Down arrows) to change concatenation order, or click the trash icon to disconnect and remove an unused slot.

---

## 3. Creating & Configuring Replacement Rules

The **Replacement Rules** section allows you to define one or more transformation steps:

### Adding & Editing Rules
- Click **`+ Add Rule`** in the section header to add a new replacement rule.
- In the **Find** box, type the exact text or pattern you wish to search for.
- In the **Replace** box, type the text you want to substitute. Leaving the Replace box empty completely deletes any matched text.

### Sequential Execution Order
Rules execute sequentially from **top to bottom**:
- Rule 1 processes the raw upstream text.
- Rule 2 receives the output of Rule 1 and applies its own substitutions.
- Rule 3 processes the result of Rule 2, and so on.

> [!TIP]
> This sequential pipeline lets you perform multi-step text refactoring. For example, Rule 1 can expand an acronym ("AGY" → "Antigravity"), and Rule 2 can format the result ("Antigravity" → "Google Antigravity Engine").

### Advanced Rule Settings (`...` Menu)
Click the three-dot options icon next to any rule to configure advanced matching behaviors:

- **Case Sensitive (`Aa`)**:
  - By default, matching is case-insensitive ("apple" matches "Apple" and "APPLE").
  - Enabling Case Sensitive requires an exact capitalization match. When active, a small indicator dot appears on the menu icon.
- **Regular Expression (`.*`)**:
  - Enables pattern-based matching for dynamic text extraction and replacement.
  - Useful for matching numbers (`\d+`), email patterns, or variable tag conventions.
- **Delete Rule**:
  - Permanently removes the rule from the node.

---

## 4. Live Verification & The Preview Drawer

You never have to guess whether your rules are matching properly:

1. **Live Replacement Counter**:
   - The status bar at the bottom displays real-time match metrics (e.g. `14 replacements applied`) with an active connection indicator.
   - If no upstream nodes are connected, it displays `Waiting for upstream input...`.
2. **Live Transformation Preview (`[ 👁 Preview ]`)**:
   - Click the **`Preview`** toggle in the bottom right corner to open the built-in result drawer.
   - This drawer renders the live transformed text immediately as you type your rules, allowing you to visually verify that replacements are accurate before piping the text downstream.

---

## 5. Troubleshooting & Quick Fixes

| Issue | Likely Cause | Solution |
| :--- | :--- | :--- |
| **No replacements occur** | The search text does not exist in the connected upstream text, or Case Sensitive is enabled. | Click **`Preview`** to inspect the incoming text. If Case Sensitive (`Aa`) is active in the rule settings, ensure your search capitalization matches. |
| **Text disappears unexpectedly** | The Replace field was left empty, which instructs the node to delete all occurrences of the found text. | Type your desired replacement text in the Replace field, or delete the rule if you did not intend to erase matches. |
| **Rules interfere with each other** | Earlier rules changed words that later rules were expecting to find. | Review the top-to-bottom rule order. Remember that Rule 2 operates on the output of Rule 1. |
| **Want to route only one transformed node** | You connected to the top-level `All out` port instead of an individual port. | Connect your downstream wire from the specific `OUT` port next to the desired input slot rather than the top `All out` port. |