Format a string with '{0}','{1}'...
目前為
此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.greasyfork.org/scripts/453846/1110440/string%20format.js
(function () {
"use strict";
if (!String.prototype.format) {
String.prototype.format = function () {
var args = arguments;
return this.replace(/{(\d+)}/g, (match, number) => {
return typeof args[number] != 'undefined' ? args[number] : match;
});
};
} else {
throw 'String.prototype.format defined.';
}
})();