format
Input Stack:
|
⇨ | Output Stack:
|
Format a string using printf-style formatting patterns. This allows for dynamic string construction by substituting values from a list into placeholders in a format string.
Parameters¶
- pattern: A string containing format specifiers (e.g.,
%s,%d,%f) - args: A list of values to substitute into the format placeholders
Format Specifiers¶
Common format specifiers supported:
* %s - String representation of any object
* %d - Decimal integer
* %f - Floating point number
* %x - Hexadecimal representation
* %% - Literal percent sign
For complete formatting options, see the Java Formatter documentation.
Examples¶
Basic string substitution:
foo%s,(,bar,),:format
| Pos | Input | Output |
|---|---|---|
| 0 | List(bar) | foobar |
| 1 | foo%s |
This substitutes the string "bar" from the list into the %s placeholder in "foo%s",
resulting in "foobar".