View Full Version : Javacript word search question

02-26-2011, 08:26 PM
This example works fine to match a users input.

if ((word[0]=="my") && (word[1]=="name") && (word[2]=="is") && (input.search(/(john|paul|zack)/)!=-1) && (num_of_words== 4))
{document.result.result.value = "Well, nice to meet you "+word[3]+".";
return true;}

Can you however do a search on what would be word[3] in the example above. Something like:


I want to be able to search only word[3] for the names john, paul and zack not the entire sentence however I need to keep the basic format of the example intact. Thanks!