ComfyUI Node: rfind

Class Name

Basic data handling: StringRfind

Category
Basic/STRING
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

rfind Description

StringRfind locates the last occurrence of a substring in a string, returning its highest index or -1.

rfind:

The StringRfind node is designed to help you locate the last occurrence of a specified substring within a given string. This functionality is particularly useful when you need to determine the position of a substring from the end of the string, allowing you to handle strings more effectively in your projects. The node returns the highest index where the substring is found, providing a straightforward way to pinpoint its location. If the substring is not present, the node will return -1, indicating its absence. Additionally, you can refine your search by specifying optional start and end parameters, which limit the search to a specific portion of the string. This flexibility makes StringRfind a powerful tool for string manipulation tasks, enabling you to efficiently manage and analyze text data.

rfind Input Parameters:

string

The string parameter is the main text in which you want to search for the substring. It serves as the primary input for the node, and the search operation will be conducted within this text. The default value is an empty string, meaning if no input is provided, the node will operate on an empty string.

substring

The substring parameter specifies the sequence of characters you are looking to find within the main string. This is the target of the search operation, and the node will return the highest index of its occurrence. The default value is an empty string, which means if no substring is specified, the node will search for an empty string within the main string.

start

The start parameter is optional and allows you to define the starting index from which the search should begin. This can be useful if you want to ignore a portion of the string before a certain point. The default value is 0, which means the search will start from the beginning of the string. The minimum value is 0, ensuring that the search does not start from a negative index.

end

The end parameter is also optional and specifies the ending index at which the search should stop. This parameter helps in limiting the search to a specific section of the string. The default value is 0, which indicates that the search will continue to the end of the string unless specified otherwise. The minimum value is 0, ensuring that the search does not extend beyond the string's length.

rfind Output Parameters:

index

The index output parameter provides the highest index where the specified substring is found within the main string. If the substring is present, this index indicates the starting position of its last occurrence. If the substring is not found, the node returns -1, signaling its absence. This output is crucial for determining the position of substrings and can be used in further string processing tasks.

rfind Usage Tips:

  • Use the start and end parameters to narrow down your search to a specific section of the string, which can improve performance and accuracy when dealing with large texts.
  • If you are unsure whether a substring exists in the string, check the output for -1 to confirm its absence before proceeding with operations that depend on the substring's presence.
  • Consider using StringRfind in conjunction with other string manipulation nodes to build complex text processing workflows, such as extracting or modifying specific parts of a string based on the index returned.

rfind Common Errors and Solutions:

Substring not found

  • Explanation: The node returns -1 when the specified substring is not found within the given string.
  • Solution: Verify that the substring you are searching for is correctly specified and exists within the string. Double-check the start and end parameters to ensure they encompass the area where the substring is expected to be found.

Invalid start or end index

  • Explanation: Providing a start or end index that is out of bounds or negative can lead to unexpected results.
  • Solution: Ensure that the start and end parameters are within the valid range of the string's indices. The start should be greater than or equal to 0, and the end should not exceed the string's length. Adjust these parameters as needed to cover the desired portion of the string.

rfind 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.

rfind