ComfyUI > Nodes > ComfyUI-YCNodes > Text Before Keyword

ComfyUI Node: Text Before Keyword

Class Name

TextBeforeKeyword

Category
YCNode/Text
Author
yichengup (Account age: 473days)
Extension
ComfyUI-YCNodes
Latest Updated
2025-06-03
Github Stars
0.02K

How to Install ComfyUI-YCNodes

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

Text Before Keyword Description

Extracts text before a specified keyword, with case sensitivity and whitespace trimming for clean output.

Text Before Keyword:

The TextBeforeKeyword node is designed to extract a portion of text that appears before a specified keyword within a given string. This node is particularly useful for text processing tasks where you need to isolate or manipulate text segments based on the presence of certain keywords. By allowing you to specify whether the search should be case-sensitive, it provides flexibility in handling text data with varying capitalization. The node efficiently identifies the keyword's position and returns the text preceding it, trimming any trailing whitespace to ensure clean output. This functionality is beneficial for AI artists who need to preprocess text data for further analysis or creative applications.

Text Before Keyword Input Parameters:

text

The text parameter is the main input string from which you want to extract the portion before the specified keyword. It supports multiline input, allowing you to work with extensive text blocks. The default value is "Your text here", which serves as a placeholder for your actual text input. This parameter is crucial as it provides the content that the node will process to find the keyword and extract the preceding text.

keyword

The keyword parameter is the specific word or phrase you want to search for within the input text. It is a single-line input, meaning it does not support multiline entries. The default value is "keyword", which you should replace with the actual keyword you are interested in. This parameter determines the point in the text where the extraction will occur, making it essential for the node's operation.

case_sensitive

The case_sensitive parameter is a boolean option that dictates whether the keyword search should consider case differences. By default, it is set to True, meaning the search will be case-sensitive. If set to False, the node will convert both the text and keyword to lowercase before searching, allowing for case-insensitive matching. This parameter is important for ensuring that the keyword search aligns with your specific requirements regarding text capitalization.

Text Before Keyword Output Parameters:

processed_text

The processed_text output parameter provides the extracted portion of the input text that appears before the specified keyword. If the keyword is not found, the entire input text is returned. This output is crucial for further processing or analysis, as it isolates the desired text segment based on the keyword's position. The node ensures that the output is free of trailing whitespace, providing a clean and ready-to-use text segment.

Text Before Keyword Usage Tips:

  • To ensure accurate keyword matching, set the case_sensitive parameter according to the capitalization of your text data. Use True for exact matches and False for more flexible, case-insensitive searches.
  • When working with large text blocks, take advantage of the multiline support in the text parameter to input your data efficiently. This can help in processing extensive documents or text data without manual segmentation.

Text Before Keyword Common Errors and Solutions:

Keyword not found

  • Explanation: This error occurs when the specified keyword is not present in the input text.
  • Solution: Double-check the keyword for typos or case mismatches. Consider setting case_sensitive to False if the keyword might appear in different capitalizations.

Empty text input

  • Explanation: This error arises when the text parameter is left empty or contains only whitespace.
  • Solution: Ensure that the text parameter contains valid content before processing. Provide a meaningful text input to extract data from.

Invalid keyword input

  • Explanation: This error happens when the keyword parameter is left empty or contains invalid characters.
  • Solution: Enter a valid keyword that you expect to find in the text. Avoid using special characters unless they are part of the keyword.

Text Before Keyword Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-YCNodes
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 Playground, enabling artists to harness the latest AI tools to create incredible art.