javascript - Regular Expression: Match Partial or full string -
i have small script takes value text input , needs match item in array either partially or fully.
i'm struggling @ moment regular expression , syntax , wondered if pick brains.
for (var i=0; < livefilterdata.length; i+=1) { if (livefilterdata[i].match(livefilter.val())) { alert(); } }
i need livefilter.val() , regular expression match current array item livefilterdata[i] if types in h or h in text box, checks if there matching item in array. if type in or matches head, header or heading.
sorry, i've looked on web on how build regular expressions can't work out.
simple string comparison shold trick:
for (var v, = livefilterdata.length; i--;) { if (livefilterdata[i].slice (0, (v = livefilter.val().tolowercase ()).length) === v) { alert(); } }
livefilterdata should contain words in lower case.
Comments
Post a Comment