I have small script that takes the value from a text input and needs to match an item in an array either partially or fully.
I’m struggling at the moment with the regular expression and the syntax and wondered if I could pick your brains.
for (var i=0; i < liveFilterData.length; i+=1) {
if (liveFilterData[i].match(liveFilter.val())) {
alert();
}
}
I need the liveFilter.val() and Regular Expression to match the current array item liveFilterData[i] so if someone types in H or h in the text box, it checks if there is a matching item in the array. If they type in He or he then it matches Head, Header or heading.
Sorry, I’ve looked all over the web on how to build regular expressions but I can’t work it out.
Simple string comparison shold do the trick:
liveFilterData should contain the words in lower case.