<script> var s="*a*a*a*a*" for(i=0; i<=s.length; i++){ var re=/\w/g; document.write([re.test(s), re.lastIndex, '<br>']) } </script>