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

# Replace Words in Response

> Learn how to use the **Replace Words in Response** node to perform text substitutions in your LLM responses after they are generated.

The **Replace Words in Response** node allows you to define multiple find-and-replace rules to modify your LLM responses. Each replacement can use either plain text or regex patterns, with support for case-sensitive matching.

## Functionality

The **Replace Words in Response** node acts as a text transformer, finding and replacing specified patterns in your LLM responses. This can be useful for:

* Response Formatting: Standardize output formats and styling
* Content Filtering: Remove or modify unwanted content patterns
* Brand Consistency: Ensure consistent terminology in responses
* Data Transformation: Convert units or standardize numerical formats
* Response Sanitization: Clean up or modify AI-generated content

## Node Properties

For each replacement rule you add, you can configure:

* **Find:**
  * **Text to Find:** The pattern or text to search for in the response
  * **Use Regex:** Toggle to enable regular expression pattern matching
  * **Case Sensitive:** Toggle to make the pattern matching case sensitive
* **Replace:**
  * **Replacement Text:** The text to insert in place of matched content

<Note>
  You can add multiple replacement rules using the "Add a Replacement" button. Rules are applied sequentially in the order they are defined.
</Note>

## Usage Examples

### Scenario: Response Standardization

Let's say you want to ensure consistent terminology in AI responses:

1. Add a **Replace Words in Response** node after your LLM node
2. Add multiple replacements:
   * Find: "AI assistant", Replace: "Virtual Assistant"
   * Find: "artificial intelligence", Replace: "AI"
   * Find: "I think", Replace: "Based on the available information"
3. Enable "Case sensitive" where appropriate
4. This helps maintain consistent branding and professional tone in responses

### Scenario: Response Sanitization

Let's say you want to remove or mask sensitive information that the LLM might inadvertently include:

1. Add a **Replace Words in Response** node after your LLM node
2. Enable "Use regex"
3. Configure a replacement:
   * Find: `/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}/`
   * Replace: "\[REDACTED EMAIL]"
4. This will replace any email addresses in the response with "\[REDACTED EMAIL]"

## Tips and Best Practices

* Place this node immediately after LLM nodes to process their outputs
* Order your replacements carefully as they are applied sequentially
* Use regex for complex pattern matching needs
* Test replacements with various response types to ensure desired outcomes
* Consider case sensitivity requirements for your use case
* Monitor replaced content to ensure accuracy
* Keep replacement rules simple and focused for better maintenance
* Regularly review and update rules as LLM response patterns evolve
