/ Published in: JavaScript
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
//replace all whitespaces with underscore
string.replace(new RegExp(/\s/g), '_');
//replace the word 'replace' with 'replaced'
string.replace(/replace/g, 'replaced');
Comments
 Subscribe to comments
                    Subscribe to comments
                
                