finding part of a string - Javascript String Operation

Javascript examples for String Operation:String Search

Description

finding part of a string

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(){/*w ww  .  j av a2 s .c o  m*/
var string = '/folder1/folder2/folder3/',
    last = string.replace(/\//g,' ').trim().split(/\s/).pop();
document.getElementById('output').appendChild(document.createTextNode(last));
    }

      </script> 
   </head> 
   <body> 
      <div id="input">
         /folder1/folder2/folder3/
      </div> 
      <div id="output"></div>  
   </body>
</html>

Related Tutorials