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


RSS Icon Subscribe to comments

You need to login to post a comment.