Node.js examples for String:Char
Subtract the characters of a given string from another string
/* Subtract the characters of a given string from another string * /*from www . j a v a2 s .com*/ * "Abracadabra".subtract('arbd') // => "Acaabra" */ String.prototype.subtract = function ( chars ) { var out = '', str = chars + ''; if ( arguments.length > 1 ) { str = Array.prototype.join.call( arguments, '' ); } for (var i=0; i<this.length; i++) { var ch = this.charAt( i ); if ( str.indexOf( ch ) !== -1 ) { str = str.replace( ch, '' ); } else { out += ch; } } return out; };