Mega Code Archive

 
Categories / JavaScript Tutorial / Regular Expressions
 

RegExp lastIndex

The lastIndex property gets the index of where the next match begins. <html>     <body>     <script language="JavaScript">     <!--     exp=/is*/g;     str = "This is just a sample sentence.";     myArray = exp.exec(str);     document.write("Found: " + myArray[0] +". Next match starts at index: " + exp.lastIndex);     -->     </script>     </body>     </html>