Javascript examples for String:indexOf
search between a range of characters using String indexOf
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){// w w w .jav a2 s . c o m var myText = "abab"; if (myText.indexOf("ab") === 0) { console.log('starts with', 'ab'); if (myText.indexOf("ab", 2) === 2) { console.log('followed by', 'ab'); } } } </script> </head> <body> </body> </html>