Listing B
<script language="javascript">

// the string we are going to operate on
var inputstr="this is my long test string with the word long in it; hope that the regular expression does not take too LONG.";

// an empty string to hold the result
var outputstr="";

// our regular expression
var regex=/long/gi;

// run the regular expression to replace any match to our regular expression with the word short.
outputstr=inputstr.replace(regex,"short");

// pop up the string, which should be
//"this is my short test string with the word short in it; hope that the regular expression does not take too short."
alert(outputstr);

</script>