ComfyUI Node Documentation: String Function 🐍
Overview
The String Function 🐍 node is a utility node within the ComfyUI-Custom-Scripts repository. It is designed to perform specific text operations, namely appending and replacing text, which can be useful when creating workflows that involve text manipulation. This node can help streamline processes by automating tasks associated with formatting and modifying strings.
Functionality
What This Node Does
The String Function 🐍 node allows users to append multiple text inputs or replace text using simple text replacement and regex (regular expressions). This node can also tidy up the text format by adjusting spacing and punctuation, making it a versatile tool for managing and formatting string data within workflows.
Inputs
Required Inputs
-
Action: This defines whether the node will append text or perform a replacement. Users can choose between:
- Append: Combines multiple input strings into one.
- Replace: Replaces occurrences of one substring with another within the text.
-
Tidy Tags: This determines whether the output text should be formatted for readability by tidying up spaces and punctuation. Options include:
- Yes: Enables text tidy up.
- No: Leaves text as is.
Optional Inputs
- Text A: A string input that serves as the primary text for operations. It supports multiline input.
- Text B: A string input that is either appended or used as the search text for replacements. It supports multiline input.
- Text C: In replace mode, this is the string used to replace occurrences of Text B in Text A. It supports multiline input.
Outputs
- Result: The node produces a single string output, which is the result of either the appended or replaced text. This output can be utilized in further nodes or parts of the workflow requiring text input.
Use in ComfyUI Workflows
The String Function 🐍 node can be integrated into workflows where text manipulation is necessary. Below are some example use cases:
- Text Concatenation: Combine several text inputs into a single string to prepare a finalized text block.
- Tag Management and Formatting: Insert commas between tags or keywords to create a cleaner list of tags for tagging systems.
- Regex-Based Text Replacement: Automatically replace portions of text using patterns, useful for text normalization or applying complex replacements.
Special Features and Considerations
- Regex Support: When using the replace action, Text B can start and end with a slash ("/pattern/") to invoke regex-based substitution, allowing for advanced search and replace capabilities.
- Tidying Up: In append mode, tidy tags feature adds commas between tags and other content, which is customizable according to the user's text handling needs.
- User-Friendly: The node allows for multiline inputs and provides dynamic prompts, facilitating easier handling of longer and more complex text blocks.
This node is an efficient tool for anyone looking to incorporate string manipulation into their ComfyUI workflows, enhancing the versatility and functionality of text handling across various processes. Visit the ComfyUI-Custom-Scripts GitHub repository for more information about this node and its integration within the custom scripts ecosystem.