Examples of Replace and test
<SCRIPT LANGUAGE="JavaScript1.2">
newstr=str.replace(re, "$2, $1");
</SCRIPT> // Prints out Smith, John
Suppose re is a RegExp object and str a string, then:
function testinput(re, str){
midstring = " contains ";
midstring = " does not contain ";
document.write (str + midstring + re.source);
Prints out a summary of matching result