Javascript examples for String:indexOf
Get all indexes of a pattern in a string
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* w w w .jav a 2 s .co m*/ var str = "abcdab"; var re = /a/g; var matches; var indexes = []; while (matches = re.exec(str)) { indexes.push(matches.index); } console.log(indexes); } </script> </head> <body> </body> </html>