Use regex to trim string - Node.js String

Node.js examples for String:Trim

Description

Use regex to trim string

Demo Code

String.prototype.trim = function() {
  return (this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, ""));
}

Related Tutorials