Is String supplant - Node.js String

Node.js examples for String:Parse

Description

Is String supplant

Demo Code


String.prototype.supplant = function (o) {
    return this.replace(/\{([^{}]*)\}/g, function (a, b) {
        var r = o[b];
        return typeof r === 'string' || typeof r === 'number' ? r : a;
    });//from  w ww .j  av  a 2s  .co  m
};

Related Tutorials