Q:

JavaScript color strings when they appear

I was wondering if there are any JavaScript functions that I could use to change the font color of certain strings in a text box. 
Suppose I created a text box and every time the string hello appeared the font color would change to blue. 
Are there any easy ways to make a database of strings so that this event would occur? 
thanks! 

A:

This is a non-trivial task, as text within a textarea can not be directly formatted.  I would look into using a div or some other applicable tag, and use the Content Editable attribute.  This way the user can edit the text and you can control the formatting.  At the simplest level you can listen for a key press and use regular expressions or the replace method to highlight all the words in your dictionary. 
Here's a start, you'll need to flesh it out to perhaps be case-insensitive if that's what you want, and to keep track of the caret position which is a more complicated task:
http://jsfiddle.net/VJQHD/
You can look at a similar issue here: Get caret (cursor) position in contentEditable area containing HTML content

