indexOf("what")-what if i want to find all the what's in this sentence full of what's

damm, this week looks like its never ending…
can anyone help me out here?

“what if i want to find all the what’s in this sentence full of what’s?”
i cant do this with indexOf, and it wont work either with lastIndexOf, since there are 3…

i’m asking this because i’m trying to do a simple htmlText editor and got stuck in the part where i cant check the selected word’s position only with indexOf…

thanks in advance!!