ComfyUI > Nodes > Basic data handling > substitute

ComfyUI Node: substitute

Class Name

Basic data handling: RegexSub

Category
Basic/STRING/regex
Author
StableLlama (Account age: 861days)
Extension
Basic data handling
Latest Updated
2026-05-07
Github Stars
0.04K

How to Install Basic data handling

Install this extension via the ComfyUI Manager by searching for Basic data handling
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Basic data handling 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

substitute Description

RegexSub node enables text substitution in strings using regex for efficient data manipulation.

substitute:

The "Basic data handling: RegexSub" node is designed to facilitate the substitution of text within a string using regular expressions. This node allows you to identify specific patterns within a string and replace them with a designated replacement string. It is particularly useful for tasks that require text manipulation, such as formatting, data cleaning, or transforming text data to meet specific criteria. By leveraging the power of regular expressions, this node provides a flexible and efficient way to perform complex text substitutions, making it an essential tool for anyone working with text data in creative or data-driven projects.

substitute Input Parameters:

string

This parameter represents the input string where the substitution will take place. It is the text data that you want to manipulate by replacing certain patterns with a replacement string. There are no specific minimum or maximum values for this parameter, as it can be any string.

pattern

The pattern parameter is a regular expression that defines the text pattern you want to find and replace within the input string. It allows you to specify complex search criteria using regex syntax, enabling precise control over which parts of the string are targeted for substitution. There are no specific minimum or maximum values for this parameter.

repl

This parameter specifies the replacement string that will replace each match of the pattern found in the input string. It can be any string that you want to use as a substitute for the matched patterns. There are no specific minimum or maximum values for this parameter.

count

The count parameter determines the maximum number of pattern occurrences to be replaced in the input string. By default, it is set to 0, which means all occurrences will be replaced. You can specify a positive integer to limit the number of replacements, allowing for more controlled text manipulation.

substitute Output Parameters:

STRING

The output of this node is a string that reflects the result of the substitution operation. It contains the modified version of the input string, where the specified patterns have been replaced with the replacement string. This output is crucial for verifying the success of the substitution and for further processing or analysis of the modified text data.

substitute Usage Tips:

  • Use regular expressions to define complex patterns for substitution, allowing for precise text manipulation.
  • Set the count parameter to limit the number of replacements if you only want to replace a specific number of occurrences.

substitute Common Errors and Solutions:

Invalid regular expression

  • Explanation: This error occurs when the pattern parameter contains a syntax error or an unsupported regex feature.
  • Solution: Review the pattern for any syntax errors and ensure it adheres to the supported regex syntax.

Replacement string not specified

  • Explanation: This error happens when the repl parameter is not provided, resulting in an inability to perform the substitution.
  • Solution: Ensure that a valid replacement string is specified in the repl parameter to enable the substitution process.

substitute Related Nodes

Go back to the extension to check out more related nodes.
Basic data handling
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.

substitute