We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
var code='123' var frstcode='ph001' var aftercode='ph002' var str='修改商品编码%s由%s改为%s' String.prototype.format = function() { if(arguments.length == 0) return this; var param = arguments[0]; var s = this; if(typeof(param) == 'object') { for(var key in param) s = s.replace(new RegExp("\\{" + key + "\\}", "g"), param[key]); return s; } else { for(var i = 0; i < arguments.length; i++){ s = s.replace(new RegExp("%s"), arguments[i]); } return s; } } var str1=str.format(code,frstcode,aftercode) console.log(str1) //修改商品编码123由ph001改为ph002
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: