Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function highlight(value, term) {
- var pattern='\\b(?=\\w)' + term;
- var regex = new RegExp(pattern, 'gi');
- return value.replace(regex, '<strong>' + term + '</strong>');
- }
- function matchSubset4(s, sub) {
- s = s.toLowerCase();
- var pattern='\\b(?=\\w)' + sub;
- var regex = new RegExp(pattern, 'gi');
- return regex.test(s);
- }
- function doMatch(s, sub){
- if(matchSubset4(s,sub)){
- document.writeln(highlight(s,sub)+"<br/>");
- }
- }
- var predictive_search = new Array('sdaf taf' ,'testing report\'s to moderator' ,'zzzzzzzzzz');
- doMatch(predictive_search[0],'t');
- doMatch(predictive_search[1],'testing report');
- doMatch(predictive_search[1],'s to');
Add Comment
Please, Sign In to add comment