/ Published in: JavaScript
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 var str = "This string has too many spaces."; var result = str.replace(/\s/gi, "_"); document.write(result);
Comments
                    Subscribe to comments
                
                