I'm very sorry for my mistake, though you still shouldn't need the \n in them at least because this is part of both \s and $.
quote:
Originally posted by TazDevil
code:
words_wrong = new Array("teh", "tehn");
words_right = new Array("the", "then");
for(i = 0; i < words_wrong.length; i++)
{
message = message.replace(/(^|\s|\n)+ words_wrong[i] +($|\s|\n)/gi, "$1"+words_right[i]+"$2");
}
return message;
so what is wrong here? how can i add a variable in the regexp expression...
There is no way that I have fount to be able to have a variable in a regular expression, I don't think it is possible (though I could be wrong).