On the previous page you replaced two occurrences of Fred but one (fred) remained.  Save replace.html as case.html.

Ignoring case in searches

To find both Fred and fred you add the regular expression modifier for case insensitive search.  To do that add an i after the g which is already there.  No spaces or anything else just add it straight after the g.  Try the case.html and all three should now be changed.

Changing case

You might also want to change the case of a letter or word or words.  Using what you have just learned you could search for, extract and change just the first letter of any word or a particular word.  Then put it back into the string.  As mentioned before you may not have need to do much changing of text in JavaScript so this example keeps it simple just so you know it is possible.  Add this line of code just before the alert line which is the last line of your code:


The method toLowerCase() takes the current contents of newVersion, puts all capitals to lower case and saves that back in the variable.  When the alert appears there are no capitals.

Try toUpperCase as well.