Node.js examples for String:Strip
String truncate
String.prototype.truncate = function(len){ len = (len!=null) ? len : 25;/* w w w . j a v a 2s .c om*/ var re = this.match(RegExp("^.{0,"+len+"}[\S]*")); var l = re[0].length; re = re[0].replace(/\s$/,''); if(l < this.length) { re = re + "…"; } return re; };