Visit ComfyUI Online for ready-to-use ComfyUI environment
Dynamic text manipulation node for replacing target strings with alternatives, featuring wildcard expansions and deterministic results.
The PromptReplace node is designed to facilitate dynamic text manipulation by replacing specified target strings within a given input string with alternative text. This node is particularly useful for AI artists who want to create adaptive and varied prompts by leveraging wildcard expansions and controlled randomness. By using a seeded random generator, PromptReplace ensures that the replacements can be deterministic, allowing for consistent results across different runs with the same seed. This feature is beneficial for generating creative content where variability is desired, yet reproducibility is also important. The node processes the input by normalizing the context, expanding wildcards, and applying regex-based replacements, making it a powerful tool for text customization and prompt generation.
This parameter represents the input text in which replacements will be made. It is the base content that you want to modify by replacing certain parts with new text. The input string can be multiline, allowing for complex and extensive text manipulations.
The target_string specifies the text or pattern you want to replace within the input string. It can include wildcards, which will be expanded once to determine the exact targets for replacement. This allows for flexible and dynamic identification of text segments to be replaced.
This parameter defines the text that will replace the occurrences of the target_string in the input. Like the target_string, it can also include wildcards, which are expanded for each replacement, enabling varied and context-sensitive substitutions.
The seed parameter is an integer that initializes the random number generator used for wildcard expansion and replacement selection. By setting a specific seed, you can ensure that the replacements are consistent across different executions, which is useful for reproducibility.
This parameter sets the maximum number of replacements to perform. If set to zero, there is no limit, and all occurrences of the target_string will be replaced. This allows you to control the extent of modifications applied to the input string.
The category parameter is optional and can be used to specify a particular category for wildcard resolution. This helps in organizing and managing different sets of wildcards, ensuring that the replacements are contextually appropriate.
The context parameter provides additional information that can be used during wildcard expansion. It is a dictionary of dictionaries, where each key-value pair represents a specific context that influences how wildcards are resolved, allowing for more tailored and precise replacements.
The result is the modified version of the input string after all specified replacements have been applied. It reflects the changes made by substituting the target_string with the replace_string, providing the final output of the node's operation.
This output provides the normalized context used during the replacement process. It is a dictionary that shows how the input context was interpreted and applied, offering insights into the wildcard resolution and replacement logic.
target_string and replace_string to create dynamic and varied text outputs, enhancing creativity and adaptability in your prompts.target_string contains invalid characters or patterns that cannot be compiled into a regular expression.target_string is correctly formatted and does not include unsupported regex syntax. Use escape characters if necessary.limit.limit parameter if you want more replacements to occur, or set it to zero for unlimited replacements.context could not be normalized into the expected format.context is a dictionary of dictionaries and that all keys and values are correctly structured.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.