var regex="";
var teststr="";
function validate_one()
{
regex=/^\d{5} \d{6}$/;
teststr=document.re1.areacode.value + " " + document.re1.phoneno.value;
if (regex.test(teststr))
{
alert("Valid phone number");
}
else
{
alert("Not a valid phone number");
}
}
function validate_two()
{
document.re2.longtext.value=document.re2.longtext.value.replace(/2002/g,"2003");
}
function validate_three()
{
regex=/^\d\d\d\d\d$/;
teststr=document.re3.fivedigits.value;
if (regex.test(teststr))
{
alert("Five Digits");
}
else
{
alert("Not Five Digits");
}
}
function validate_four()
{
regex=/^\d{1,3}$/;
teststr=document.re4.one2threedigits.value;
if (regex.test(teststr))
{
alert("Between one and three digits");
}
else
{
alert("Not between one and three digits");
}
}
function validate_five()
{
regex=/^[a,b,c,x,y,z]{3}\d{3}$/;
teststr=document.re5.complexpattern.value;
if (regex.test(teststr))
{
alert("Matches");
}
else
{
alert("Does not Match");
}
}
function testRE()
{
var myregex=new RegExp("test");
myregex.compile(document.re6.myregex.value);
teststr=document.re6.mysample.value;
if (myregex.test(teststr))
{
alert("Matches");
}
else
{
alert("Does not Match");
}
}
function testRE1()
{
var myregex=new RegExp("test");
var replaceWith=document.re6.replacewith.value;
var argstring="";
// check for arguments
if (document.re6.global.checked)
{
argstring = argstring + "g";
}
if (document.re6.caseinsensitive.checked)
{
argstring = argstring + "i";
}
// if we have arguments
if (argstring.length>0)
{
myregex.compile(document.re6.myregex1.value,argstring);
}
else
{
myregex.compile(document.re6.myregex1.value);
}
teststr=document.re6.mysample1.value;
document.re6.mysample1.value=teststr.replace(myregex,replaceWith);
}