VAN
DEL
.IO

Regular Expression – RegEx cheatsheet

match anything with regex

Javascript

 




function findSearchResults(searchval, products){
	console.log('findSearchResults', products);

	var regEx = searchval.toLowerCase()+'\w*';
    var re = new RegExp(regEx, 'gm');
    var m;
    
    var replace = regEx;
    var index = 0;
    for(var cat in products){
        
    	products[cat].filter((obj, v) => {
    		if ((m = re.exec(obj.name.toLowerCase())) !== null) {
	            console.log('matched regex', obj.name)
	            //pushToResults(obj, cat, obj.name, index);
	        	
	        }else{
	            console.log('NOT matched regex', obj.name)
	        }
    	})
    	index++;
    }

    //setSearchResultMarkup()
	
}