# Searching multiple instances of word using javascript?

**URL:** <https://forum.kirupa.com/t/searching-multiple-instances-of-word-using-javascript/307770>\
**Category:** web dev\
**Created:** [April 9, 2010, 8:49pm UTC](https://forum.kirupa.com/t/searching-multiple-instances-of-word-using-javascript/307770 "2010-04-09T20:49:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![boebarl1](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@boebarl1](https://forum.kirupa.com/u/boebarl1)\
**Post date:** [April 9, 2010, 8:49pm UTC](https://forum.kirupa.com/t/searching-multiple-instances-of-word-using-javascript/307770/1 "2010-04-09T20:49:11Z")

</div>

I am writing this script where I want to search a paragraph for every instance of a particular word. I am simply using the indexOf phrase which returns only the index of the first instance? Does anyone know of like a indexOfAll (something like that), or do I need to try and loop this somehow? Any help will be greatly appreciated, Here is what I am working with.

var sentance = “A cubist cubed two cubes and ended up with eight. Was she Cuban?”;  
var cube = “cube”;

document.writeln("\<p\>The word cube is located at index’s of " + sentance.indexOf( cube ) + “\</p\>” );
