I
iannorton
Hi,
I'm trying to write a RegExp that will return search an array and
return the closest 10 matches, for example, if i entered "Hel" and my
array contained "Hello", "Hell", it would return Hello and Hell,
however, if i entered "ell" it wouldn't return anything.
The code that i need to modify is: -
var searchterm = "Hel";
var re = new RegExp("\\^")
re = /\^/
if(searchterm !='')
{
var matches = 0;
for(var i=0; i<myarray.length; i++)
{
if(searchme != false)
{
if (searchterm == myarray)
{
write (myarray);
matches++;
}
}
if(matches==10) break
}
}
Obviously this is only returning exact matches and having tried to add
the RegExp into there hasn't worked as yet.
Any pointers or tips on this would be great.
Thanks in advance,
Ian
I'm trying to write a RegExp that will return search an array and
return the closest 10 matches, for example, if i entered "Hel" and my
array contained "Hello", "Hell", it would return Hello and Hell,
however, if i entered "ell" it wouldn't return anything.
The code that i need to modify is: -
var searchterm = "Hel";
var re = new RegExp("\\^")
re = /\^/
if(searchterm !='')
{
var matches = 0;
for(var i=0; i<myarray.length; i++)
{
if(searchme != false)
{
if (searchterm == myarray)
{
write (myarray);
matches++;
}
}
if(matches==10) break
}
}
Obviously this is only returning exact matches and having tried to add
the RegExp into there hasn't worked as yet.
Any pointers or tips on this would be great.
Thanks in advance,
Ian