Question

I've got the following keyword matcher:

http://jsfiddle.net/y8Gd4/

If one types for example "un", "Sun" or "Spa" it returns true for the first div with data-keywords attr with value "Sun" or second with "Spain".

But if one types "sun" or "spa" it returns false for both divs in IE 7/8/9 and Chrome 28.0 although there's an option which should make the method case insensitive.

In FF 22.0 it works fine.

Any idea why IE/Chrome omits the "i" insensitive flag?

Was it helpful?

Solution

To make it work, you either need to write inline like this: /myphrase/gi or pass the RegExp object for phrase.match(), like below:

var search = new RegExp(keyword[j], "gi");
phrase.match(search) ? match = true : match = false;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top