HTML nbsp To Space and space to nbsp - Node.js String

Node.js examples for String:HTML String

Description

HTML nbsp To Space and space to nbsp

Demo Code

  String.prototype.nbspToSpace = function() {
    return this.replace(/ /g, " ").replace(/\u00A0/g, " ");
  }/*  www.j ava 2s . c  o  m*/
  
  String.prototype.spaceToNbsp = function() {
//    return this.replace(/\s/g," ");
    return this.replace(/\s/g,"\u00A0");
  }

Related Tutorials