ComfyUI > Nodes > ComfyUI-LogicUtils > Replace String

ComfyUI Node: Replace String

Class Name

ReplaceString

Category
Logic Gates
Author
aria1th (Account age: 3016days)
Extension
ComfyUI-LogicUtils
Latest Updated
2026-01-21
Github Stars
0.1K

How to Install ComfyUI-LogicUtils

Install this extension via the ComfyUI Manager by searching for ComfyUI-LogicUtils
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-LogicUtils in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Replace String Description

Facilitates text manipulation by replacing specific patterns in strings using regular expressions.

Replace String:

The ReplaceString node is designed to facilitate the process of text manipulation by allowing you to search for specific patterns within a string and replace them with a different text. This node is particularly useful for tasks that involve text processing, such as cleaning up data, modifying text content, or preparing strings for further analysis. By leveraging regular expressions, the ReplaceString node provides a powerful and flexible method to perform complex text substitutions, making it an essential tool for AI artists who need to automate and streamline their text editing workflows.

Replace String Input Parameters:

String

This parameter represents the input string that you want to modify. It is the text in which the node will search for the specified pattern and perform the replacement. The input string can be of any length and may contain any characters. There are no specific minimum or maximum values, but the default is an empty string.

Regex

The Regex parameter is a string that defines the regular expression pattern to search for within the input string. Regular expressions are sequences of characters that define a search pattern, allowing for complex and flexible text matching. This parameter is crucial as it determines which parts of the input string will be replaced. The default value is an empty string, meaning no pattern is specified initially.

ReplaceWith

This parameter specifies the text that will replace the matched patterns found in the input string. It allows you to define what the matched text should be substituted with, providing the flexibility to customize the output string. The default value is an empty string, indicating that the matched text will be removed if no replacement text is provided.

Replace String Output Parameters:

STRING

The output of the ReplaceString node is a modified version of the input string, where all occurrences of the specified pattern have been replaced with the provided replacement text. This output is crucial for verifying that the desired text transformations have been successfully applied, enabling you to proceed with further processing or analysis of the modified string.

Replace String Usage Tips:

  • Use specific and well-defined regular expressions to accurately target the text you want to replace, ensuring that only the intended parts of the string are modified.
  • Test your regular expressions with sample data to verify that they match the desired patterns before applying them to larger datasets, minimizing the risk of unintended replacements.

Replace String Common Errors and Solutions:

Invalid regular expression

  • Explanation: This error occurs when the provided Regex parameter contains a syntax error or an unsupported pattern.
  • Solution: Review the regular expression for any syntax errors or unsupported constructs, and ensure it adheres to the correct regular expression syntax.

No matches found

  • Explanation: This error indicates that the specified pattern was not found in the input string, resulting in no replacements being made.
  • Solution: Double-check the Regex parameter to ensure it accurately represents the pattern you intend to match, and verify that the input string contains the expected text.

Replacement text not applied

  • Explanation: This issue arises when the ReplaceWith parameter is empty, leading to the removal of matched text without substitution.
  • Solution: Provide a valid replacement text in the ReplaceWith parameter to ensure that matched patterns are substituted with the desired content.

Replace String Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-LogicUtils
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

Replace String