C#-like String.Format() function in JQuery? [duplicate]
Is it possible to call a C#-like String.Format() function in JQuery?
Equivalent of String.format in JQuery
Here is the format function...
String.format = function() { var s = arguments[0]; for (var i = 0; i < arguments.length - 1; i++) { var reg = new RegExp("\\{" + i + "\\}", "gm"); s = s.replace(reg, arguments[i + 1]); } return s; }
Checkout format() that's part of the validation plugin that does C# like string formatting.
精彩评论