How to replace all whitespace characters in a string with an underscore (_) in JavaScript

1 Answer

0 votes
var s = 'PHP CSS JavaScript HTML Symfony';

s = s.replace(/\ /g, '_');

document.write(s);
 
 
   
/*
run:
   
PHP_CSS_JavaScript_HTML_Symfony 
      
*/

 



answered Sep 22, 2019 by avibootz
...