Skip to content

← programming package

StringSubstitute

Replace multiple placeholders in a string using a dictionary mapping.

Each key in the substitutions dictionary represents a placeholder string that will be replaced by its corresponding value. This is useful for templating scenarios where text contains various placeholders (e.g., {{subject_id}}, {{session}}) that need to be filled in with data-dependent values.

If a placeholder from the dictionary is not found in the input string, a warning is emitted (unless verbose is set to False). This allows for flexible templates where not all placeholders may be present in every input string.

All replacement values are converted to strings before substitution. Version 1.0.0

Ports/Properties

string

String to process.

verbose name
String
default value
None
port type
DataPort
value type
str (can be None)
data direction
INOUT

substitutions

Dictionary mapping placeholder strings to their replacement values. Each key in the dictionary is a placeholder that will be replaced by its corresponding value. Values are converted to strings before substitution.

verbose name
Substitutions
default value
{}
port type
DictPort
value type
dict (can be None)

verbose

Whether to emit warnings when placeholders from the dictionary are not found in the input string.

verbose name
Verbose
default value
True
port type
BoolPort
value type
bool (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

verbose name
Set Breakpoint (Debug Only)
default value
False
port type
BoolPort
value type
bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

verbose name
Metadata
default value
{}
port type
DictPort
value type
dict (can be None)