Wow that's really stupid and makes me love regular expressions even more. Especially the fact that they use the string as the object and find macthes withing it. Though I must admit that it then does get confusing trying to remember which way exec and replace go.... (or is it match.... there are too many different ways of doing things.
The way I do checks like this is as follows
code:
if((arr = RegExpObj.exec(stringObj)) !== null){
//put some code here
}
This way not only do I get the match, I get what exactly it matched and can get lots more iformation about the match (like rest ofthe string to the left or right and havig an array of all of the matches and other stuff). I highly advise people to use this method instead. If you don't use any symbols then you can still store all of your words in an array and what is better is that you can make sure that it is that word and not part of a word.
code:
var RegExpObj = new RegExp("\b("+arrayObj.join("|")+")\b");
or if you would prefer the word to be even in part of a word, like "hi" will be found in "this" for example with the following code (but not hte previous)
code:
var RegExpObj = new RegExp("("+arrayObj.join("|")+")");
Both of these can be really useful when coding something that the user might edit, you just need to remember the put a \ before any special symbols that will be used (eg "$", "^", ".", etc.).
This method would mean that you do not need the for statement but would just be using a regular expression in your if statemet instead.
I understand if this has just gone way over your head but other members like roflmao might find this useful for future scripts.