C'e` una funzione pronta in JS:
str.indexOf()

Per riferimento: http://www.devguru.com/technologies/...ef/string.html