I'm abstracting my code a bit as it is eventually going into a commercial product. I'm having some trouble getting a regex test to return the proper results.
var files = [
"Jurassic%20Park%20-%20Nedry.mp4",
'Jeb%20Corliss%20Grinding%20The%20Crack.mp4'
];
var filterSearch = function(text){
var filter = new RegExp(text, 'gi');
var displayFiles = files.filter(function(file){
return filter.test( file.toLowerCase());
});
console.log(displayFiles);
}
If I run filterSearch('J') or filterSearch('N') I'd expect to get 2 results, Jurassic Park and Jeb, instead I'm just getting one. It seems to work properly for all the other characters shared between the two files, but not for J or N. Does anyone know why this isn't working properly for me? Thanks,
Edit: I'm able to repeat this on repl.it .