string format

Format a string with '{0}','{1}'...

2022/10/28のページです。最新版はこちら。

このスクリプトは単体で利用できません。右のようなメタデータを含むスクリプトから、ライブラリとして読み込まれます: // @require https://update.greasyforks.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.';
    }
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。