api/LibDeformat-3.0

LibDeformat.Deformat(text, pattern)

Return the arguments of the given format string as found in the text.

Parameters

text
The resultant formatted text.
pattern
The pattern used to create said text.

Return value

a tuple of values, either strings or numbers, based on the pattern.

Usage

LibDeformat.Deformat("Hello, friend", "Hello, %s") == "friend"
LibDeformat.Deformat("Hello, friend", "Hello, %1$s") == "friend"
LibDeformat.Deformat("Cost: $100", "Cost: $%d") == 100
LibDeformat.Deformat("Cost: $100", "Cost: $%1$d") == 100
LibDeformat.Deformat("Alpha, Bravo", "%s, %s") => "Alpha", "Bravo"
LibDeformat.Deformat("Alpha, Bravo", "%1$s, %2$s") => "Alpha", "Bravo"
LibDeformat.Deformat("Alpha, Bravo", "%2$s, %1$s") => "Bravo", "Alpha"
LibDeformat.Deformat("Hello, friend", "Cost: $%d") == nil
LibDeformat("Hello, friend", "Hello, %s") == "friend"



Comments

Posts Quoted:
Reply
Clear All Quotes