Javascript examples for String:split
Split a string using substring and indexOf
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from ww w .j a v a 2 s. c o m var a = 'Base-Shirt_Stripe.jpg'; var split = a.substring(0,a.indexOf('.')).split('_'); console.log(split[0]); //Base-Shirt console.log(split[1]); //Stripe } </script> </head> <body> </body> </html>