quote:
Originally posted by Mattike
Use regular expressions!
code:
var nMessage = Message.replace(/(^|\s|\n)teh($|\s|\n)/gi, "$1the$2");
Why use such a complex regular expression when you can do the same by this.
code:
var nMessage = Message.replace(/teh/gi, "the");
This will do exactly the same thing as what your regular expression did except it is smaller and less confusing for those that are new to regular expressions.