Javascript String swap_text(surrogates)

Description

Javascript String swap_text(surrogates)


String.prototype.swap = function swap_text(surrogates) {
    "use strict";
    var n, text = this;
    for (n in surrogates) {
        if (surrogates.hasOwnProperty(n)) {
            text = text.replace(new RegExp("{" + n + "}", "g"), surrogates[n]);
        }/* ww  w .  ja  v  a2  s  .c om*/
    }
    return text;
};



PreviousNext

Related