Replace Spaces with Underscores


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



Copy this code and paste it in your HTML
  1. var str = "This string has too many spaces.";
  2. var result = str.replace(/\s/gi, "_");
  3. document.write(result);

Report this snippet


Comments


You need to login to view comments.