Trim string white spaces using regular expressions


/ Published in: JavaScript



Copy this code and paste it in your HTML
  1. trimWS = function(str) {
  2. str = str.replace(/^\s*/, "");
  3. str = str.replace(/\s*$/, "");
  4. return str;
  5. },

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.