I am looking to find matches to the first 4 letters of a string. I know it's got to use regex but my attempts have just left me banjaxed. But it should be something like....
onClick="matchString('a10109')"
function matchString(string)
{
var mystring = (string);
//now get the first 4 letters of the string
some sort of regex here!!!
// now get the div tags then check their id's for the same first 4 letters
var divs=document.getElementsByTagName("DIV");
for (i=0;i<divs.length;i++)
//use my regex here
if(divs.getElementsByTagName("id")='MYREGEX')
{
divs.style.display='block';
}
}
}
Any help would be appreciated.
"Away from the actual ... everything is virtual"
onClick="matchString('a10109')"
function matchString(string)
{
var mystring = (string);
//now get the first 4 letters of the string
some sort of regex here!!!
// now get the div tags then check their id's for the same first 4 letters
var divs=document.getElementsByTagName("DIV");
for (i=0;i<divs.length;i++)
//use my regex here
if(divs.getElementsByTagName("id")='MYREGEX')
{
divs.style.display='block';
}
}
}
Any help would be appreciated.
"Away from the actual ... everything is virtual"