Posted By

duniyadnd on 04/21/09


replace white space whitespace underscore

Versions (?)

Replace space with _

 / Published in: JavaScript

I'll never learn how to use this Markdown system. Anyway, here is the fixed code based on my comment on the following page:

I'm sorry, I don't mean to hijack the code. :(

  1. var str = "This string has too many spaces.";
  2. var result = str.replace(/(\s| |&\#160;)+/gi, "_");
  3. document.write(result);

Report this snippet  


RSS Icon Subscribe to comments
Posted By: johnshow on November 22, 2017

Markdown system not so hard as you think. Just find official documentation in their website and all be cool.

You need to login to post a comment.