Add a random string between filename and file extension in JavaScript - Javascript String

Javascript examples for String:replace

Description

Add a random string between filename and file extension in JavaScript

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from   w w w.ja va2  s.c  o  m
console.log('testtesttest'.replace(/(\.[^\.]*)?$/, '.foo$1'));

    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials