Trim string white spaces using regular expressions


/ Published in: JavaScript
Save to your folder(s)



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


You need to login to view comments.