ComfyUI  >  Nodes  >  ComfyUI Impact Pack >  String Selector

ComfyUI Node: String Selector

Class Name

ImpactStringSelector

Category
ImpactPack/Util
Author
Dr.Lt.Data (Account age: 458 days)
Extension
ComfyUI Impact Pack
Latest Updated
6/19/2024
Github Stars
1.4K

How to Install ComfyUI Impact Pack

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

Select specific text lines or blocks from input strings for manipulation based on markers or line numbers.

String Selector:

The ImpactStringSelector node is designed to help you select specific lines or blocks of text from a given string input. This node is particularly useful when you need to extract or manipulate text data based on line numbers or specific markers. It can handle both single-line and multi-line text inputs, making it versatile for various text processing tasks. The node's primary function is to allow you to choose a particular line or block of text from the input string, which can be especially beneficial in scenarios where you need to dynamically select and use different parts of a text based on certain conditions or indices.

String Selector Input Parameters:

strings

This parameter accepts the input text from which you want to select specific lines or blocks. It supports multi-line text, allowing you to input large text blocks. The text is split into lines based on newline characters. This parameter is essential as it provides the raw data that the node will process.

multiline

This boolean parameter determines whether the node should treat the input text as a single block or multiple blocks separated by lines starting with the # character. When set to True, the node will consider lines starting with # as the beginning of a new block and will concatenate lines until the next # or the end of the text. The default value is False, meaning the text is treated as individual lines by default. This parameter helps in organizing and selecting text blocks more efficiently.

select

This integer parameter specifies the index of the line or block you want to select from the input text. The index is zero-based, meaning 0 refers to the first line or block. If the specified index exceeds the number of available lines or blocks, the node will use the modulo operation to wrap around and select a valid index. The default value is 0, ensuring that the first line or block is selected by default. This parameter is crucial for dynamically choosing different parts of the text based on your needs.

String Selector Output Parameters:

STRING

The output is a single string that represents the selected line or block of text from the input. This output can be used in subsequent nodes or processes where specific text data is required. The output is directly influenced by the input parameters, particularly the select and multiline parameters, which determine which part of the input text is chosen.

String Selector Usage Tips:

  • To select a specific line from a multi-line text, ensure that the multiline parameter is set to False and use the select parameter to specify the line index.
  • When working with text blocks separated by #, set the multiline parameter to True to enable block selection. Use the select parameter to choose the desired block.
  • If you need to cycle through lines or blocks dynamically, you can use a variable or an external input to change the select parameter value.

String Selector Common Errors and Solutions:

IndexError: list index out of range

  • Explanation: This error occurs when the select parameter value exceeds the number of available lines or blocks in the input text.
  • Solution: Ensure that the select parameter value is within the valid range of indices. You can also use the modulo operation to wrap around the index.

ValueError: invalid literal for int() with base 10

  • Explanation: This error occurs when the select parameter is not a valid integer.
  • Solution: Make sure that the select parameter is set to a valid integer value. If using a variable, ensure it is properly converted to an integer before passing it to the node.

String Selector Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI Impact Pack
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.