Try to adapt from this example code:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
var arr = [ "monkey", "lion", "egg", "tiger", "elephant" ];
$("button").click(function(){
$("div").empty();
var list = "<ul>";
$.each(arr, function(index, item) {
var pattern = new RegExp("^"+ $("#txt").val() +".*");
if (item.match(pattern)){
list += "<li>"+item+"</li>";
}
});
list += "</ul>";
$("div").append(list);
});
});
</script>
</head>
<body>
<input type="text" value="" id="txt">
<br>
<button type="button">Search</button>
<div></div>
</body>
</html>
Read more:
The 30 Minute Regex Tutorial[
^]