String.format

Provides a very simplistic C# like string.Format functionality.

Note: This method is a static method on the string object, rather than an instance method:

var result = String.format("Hello {0}, the time is: {1}",
                           "Rick",new Date().formatDate("mm-dd-yy HH:mm"));

No formatting options are supported in the format expressions and only pure string replacement is performed. So formats like {0:mm-yyyy} for a date will not work for example.

String.format(formatString)

Parameters

formatString
The C# like format string. Use {0} through {n} to specify arguments to replace. Note that no other formatting options are availble (ie. no : syntax like {0:MM-yyyy} on date for example). Only basic string replacement is performed.

args
Any number of arguments. Any non-string arguments are converted with .toString().

See also:

Class String

© West Wind Technologies, 1996-2016 • Updated: 03/18/08
Comment or report problem with topic