javascript format 字符串 函数
摘要:
函数实现如下:function format(string) { var args = arguments; var pattern = new RegExp("%([1-" + arguments.length + "])", "g"); return String(string).replace(pattern, function (match, index) { return args[index]; });};用法如下:console.log(format("And the %1 want to know whose 阅读全文
posted @ 2014-04-01 21:29 Mr Code 阅读(505) 评论(0) 推荐(0) 编辑