<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script type="text/Javascript">
//<![CDATA[
function filter(el)
{
var j = 0
var strHTML = " "
var v_foundarray = new Array()
var v_array = new Array("manish","satyan","123","324","34324","565")
var v_regexp = new RegExp(el.value,"gi")
for ( var i = 0; i < v_array.length; i++ )
{
if ( v_regexp.test(v_array[i]) ) {
v_foundarray[j] = v_array[i]
// alert("Pattern found")
j++
}
}
for ( var k = 0; k < v_foundarray.length; k++ )
{
strHTML += v_foundarray[k] + "<br />"
}
document.all.vals.innerHTML = strHTML
}
//]]>
</script>
</head>
<body>
<p><b>Array contents:</b> { "manish","satyan","123","324","34324","565" } <br /> <br />
<i>Type in the regular expression by which you want to filter data in the<br />
<i>array. for example, if you want to get all the elements that end with the<br />
letter 'h' type 'h$'. </i></p>
<input id="inpText" type="text"/><input value="FILTER" type="button" onclick="filter(document.all.inpText)"/>
<div id="vals"></div>
</body>
</html>