julesfern / spahql

A query language for Javascript data. Extracted from Spah.
MIT License
325 stars 20 forks source link

Case sensitivity in String match #31

Open venki-kratos opened 9 years ago

venki-kratos commented 9 years ago

How does it work? "=~" operator does not seem to handle "/i" convention for javascript regular expressions. Great API. thanks. Looking forward to using it seriously.

venki-kratos commented 9 years ago

Probably you should consider support for /i - like below - change of syntax

"eqStringRough": function(left, right) { /* if the right ends with /i it is a case insensitive match */ var flag = "g" , pat = right; if(pat && (pat.length > 2) && (pat.substring(pat.length-2) == "/i")) { pat = pat.substring(0, pat.length-2); flag = "gi"; } return (left.match(new RegExp(pat, flag))); },

Down-side is what if "/i" is the intended search string? How does escaping work in JSON Xpath style query syntax?

thanks, again

venki-kratos commented 8 years ago

Looks like this is still not fixed in the latest master branch. Would you consider this extention to your beautiful API. thanks, Venki