Trim a string via regex - Node.js String

Node.js examples for String:Trim

Description

Trim a string via regex

Demo Code

function trim(s) {
  return s.replace( /^\s+|\s+$/g, "" );
}

Related Tutorials