/* pattern.js
** 03 Feb 2005
** Terry Sergeant
**
** Playing with Pattern Matching
**
*/
var str;
str= prompt("Enter a string with the word 'sad' in it: ");
str= str.replace(/sad/g,"happy");
document.write("The new string: "+str+"
");
str= prompt("Enter a SSN: ");
if (str.search(/^\d{3}-\d{2}-\d{4}$/)==-1)
document.write(str+" is a bogus SSN
");
else
document.write(str+" is OKAY
");
str= prompt("Enter a Name: ");
if (str.search(/\W|\d/)!=-1)
document.write(str+" contains bogus characters
");
else
document.write(str+" is OKAY
");
str= prompt("Enter a Phone Number (xxx)xxx-xxxx: ");
if (str.search(/^\(\d{3}\)\d{3}-\d{3}$/)!=-1)
document.write(str+" is not of the right form
");
else
document.write(str+" is OKAY
");
str= prompt("Enter a Valid HSU student email address: ");
if (str.search(/^[a-z]{3,4}\d{4}\@hsutx\.edu$/)==-1)
document.write(str+" is not of the right form
");
else
document.write(str+" is OKAY
");