Mask String - Node.js String

Node.js examples for String:Algorithm

Description

Mask String

Demo Code

String.prototype.ToMask = function (mascara) {
    var x = 1;/*from   w w  w. ja v a  2  s  .com*/
    var rp = mascara.replace(/(\w)/gi, function (match, contents, offset, s) {
        return "$" + x++;
    });
    return this.replace(new RegExp(this.replace(/([\w])/gi, "([\\w])")), rp);
};

Related Tutorials