String Filter:
The 1hew_StringFilter node is designed to process and refine text by filtering out unwanted elements such as comments and empty lines. This node is particularly useful for cleaning up text data, making it more readable and manageable. By allowing you to specify whether to remove comments or empty lines, it provides a flexible approach to text processing. This can be especially beneficial when dealing with large blocks of text or code, where clarity and conciseness are essential. The node's primary goal is to streamline text content, ensuring that only the relevant information is retained, which can be crucial for tasks that require clean and structured text input.
String Filter Input Parameters:
text
This parameter accepts the main text input that you wish to process. It supports multiline text, allowing you to input large blocks of text or code. The text is processed to remove specified elements based on other parameters. There is no explicit minimum or maximum value, but the default is an empty string.
filter_empty_line
This boolean parameter determines whether empty lines should be removed from the text. When set to True, any line that is empty or contains only whitespace will be excluded from the output. The default value is False, meaning empty lines will be retained unless specified otherwise.
filter_comment
This boolean parameter controls the removal of comments from the text. When enabled (True), lines starting with a # or enclosed in multiline comment quotes (""" or ''') are filtered out. This is particularly useful for cleaning up code or text files where comments are not needed. The default setting is False, allowing comments to remain unless specified otherwise.
input
This parameter allows you to insert additional text into the main text input by replacing occurrences of {input} with the specified string. It provides a way to dynamically modify the text content based on external input. The default value is an empty string.
String Filter Output Parameters:
string
The output parameter string provides the processed text after applying the specified filters. It returns a cleaned version of the input text, with comments and/or empty lines removed based on the input parameters. This output is crucial for ensuring that the text is concise and free of unnecessary elements, making it suitable for further processing or analysis.
String Filter Usage Tips:
- To effectively clean up code or text files, enable
filter_commentto remove all comments, which can help in focusing on the main content. - Use
filter_empty_lineto eliminate unnecessary whitespace, which can improve the readability of the text, especially in large documents. - Utilize the
inputparameter to dynamically insert context-specific information into your text, which can be useful for templating or generating customized outputs.
String Filter Common Errors and Solutions:
Empty Output
- Explanation: If the output is empty, it might be due to all lines being filtered out based on the selected parameters.
- Solution: Review the
filter_commentandfilter_empty_linesettings to ensure they align with your intended output. Adjust these parameters to retain necessary lines.
Unexpected Characters in Output
- Explanation: This may occur if the
{input}placeholder is not correctly replaced due to an empty or incorrectinputparameter. - Solution: Ensure that the
inputparameter is correctly set with the desired replacement text. Double-check for any typos or missing values.
