var str = '/var/www/site/Brand new document.docx'; document.write( str.replace(/s/g, '') ); Run code snippetHide results