ComfyUI  >  Nodes  >  pythongosssss/ComfyUI-Custom-Scripts >  String Function 🐍

ComfyUI Node: String Function 🐍

Class Name

StringFunction|pysssss

Category
utils
Author
pythongosssss (Account age: 538 days)
Extension
pythongosssss/ComfyUI-Custom-Scripts
Latest Updated
8/2/2024
Github Stars
1.5K

How to Install pythongosssss/ComfyUI-Custom-Scripts

Install this extension via the ComfyUI Manager by searching for  pythongosssss/ComfyUI-Custom-Scripts
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter pythongosssss/ComfyUI-Custom-Scripts 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
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

String Function 🐍 Description

Versatile text string manipulation node for AI artists, offering append, replace, and tidy functions.

String Function 🐍| String Function 🐍:

The StringFunction| String Function 🐍 node is a versatile utility designed to manipulate and transform text strings based on specified actions. This node is particularly useful for AI artists who need to dynamically modify text data within their workflows. It offers two primary actions: appending multiple text strings together or replacing parts of a text string using either direct substitution or regular expressions. Additionally, it includes an option to tidy up the resulting text by removing extra spaces and redundant commas, ensuring clean and readable output. This node simplifies text processing tasks, making it easier to manage and format text data efficiently.

String Function 🐍| String Function 🐍 Input Parameters:

action

The action parameter determines the type of text manipulation to be performed. It accepts two options: append and replace. When set to append, the node concatenates the provided text strings (text_a, text_b, and text_c). When set to replace, the node replaces occurrences of text_b in text_a with text_c. If text_b is formatted as a regular expression (enclosed in slashes), it performs a regex-based replacement. This parameter is required for the node to function correctly.

tidy_tags

The tidy_tags parameter specifies whether to clean up the resulting text by removing extra spaces and redundant commas. It accepts two options: yes and no. When set to yes, the node will tidy up the text, ensuring a cleaner output. This parameter is required and helps maintain the readability of the output text.

text_a

The text_a parameter is the primary text input for the node. It is used as the base text for both the append and replace actions. This parameter supports multiline text and does not allow dynamic prompts. It is optional but necessary for meaningful output.

text_b

The text_b parameter serves as the secondary text input. In the append action, it is one of the texts to be concatenated. In the replace action, it specifies the text or regex pattern to be replaced in text_a. This parameter supports multiline text and does not allow dynamic prompts. It is optional but crucial for the replace action.

text_c

The text_c parameter is the tertiary text input. In the append action, it is one of the texts to be concatenated. In the replace action, it specifies the replacement text for occurrences of text_b in text_a. This parameter supports multiline text and does not allow dynamic prompts. It is optional but necessary for the replace action to define the replacement text.

String Function 🐍| String Function 🐍 Output Parameters:

STRING

The STRING output parameter provides the resulting text after the specified action has been performed. This output contains the manipulated text, either concatenated or with replacements made, and optionally tidied up based on the tidy_tags setting. The output is essential for further processing or display within your workflow.

String Function 🐍| String Function 🐍 Usage Tips:

  • To concatenate multiple text strings, set the action parameter to append and provide the desired texts in text_a, text_b, and text_c.
  • For replacing text using a regular expression, enclose the regex pattern in slashes (e.g., /pattern/) in the text_b parameter and set the action parameter to replace.
  • Enable the tidy_tags parameter to yes to automatically clean up the resulting text, removing extra spaces and redundant commas for a polished output.

String Function 🐍| String Function 🐍 Common Errors and Solutions:

Invalid regular expression

  • Explanation: This error occurs when the text_b parameter is intended to be a regex pattern but is not correctly formatted.
  • Solution: Ensure that the regex pattern in text_b is enclosed in slashes (e.g., /pattern/).

Missing required parameters

  • Explanation: This error occurs when one or more required parameters (action or tidy_tags) are not provided.
  • Solution: Make sure to specify values for both the action and tidy_tags parameters.

Replacement text not provided

  • Explanation: This error occurs when the replace action is selected, but text_c is not provided.
  • Solution: Ensure that text_c is specified when using the replace action to define the replacement text.

String Function 🐍 Related Nodes

Go back to the extension to check out more related nodes.
pythongosssss/ComfyUI-Custom-Scripts
RunComfy

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.