Skip to main content

simple_format

Format string, expanding abbreviations in keys'.

def simple_format(
s: string,
keys: dict[str, str | Callable],
pattern: Pattern[str],
expand: string
) - > string

Format string, expanding abbreviations in keys'.

Parameters

NameTypeDescription
sstringThe input string containing abbreviations or placeholders to be expanded.
keys`dict[str, strCallable]`
patternPattern[str]A compiled regular expression used to identify the placeholders within the input string; defaults to RE_FORMAT.
expandstringThe expansion string used on the match object to extract the specific key name from the matched pattern; defaults to the first capturing group.

Returns

TypeDescription
stringThe formatted string with all matched patterns replaced by their corresponding values or function results from the keys dictionary.