Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用jquery text.match()函数过滤不区分大小写的文本_Javascript_Jquery_Full Text Search - Fatal编程技术网

Javascript 如何使用jquery text.match()函数过滤不区分大小写的文本

Javascript 如何使用jquery text.match()函数过滤不区分大小写的文本,javascript,jquery,full-text-search,Javascript,Jquery,Full Text Search,我正在尝试使搜索不敏感,但它将只匹配大写字母,我希望同时使用大写和小写进行搜索。这是我的代码 function keyup(idd){ var searchTerm = $("#tags"+idd).val(); $("#sss"+idd+' option').each(function(){ if($(this).text().match(searchTerm

我正在尝试使搜索不敏感,但它将只匹配大写字母,我希望同时使用大写和小写进行搜索。这是我的代码

              function keyup(idd){
                  var searchTerm = $("#tags"+idd).val();
                  $("#sss"+idd+' option').each(function(){
                  if($(this).text().match(searchTerm)){ 
                      $(this).show();
                } 
                else{
                    $(this).hide();
                }
            });
           } 

任何人都可以帮助我。谢谢您使用构造函数:

$(this).text().match(new RegExp(searchTerm, "i"))
使用
toLowerCase()


你可以试试这样的东西,而不是火柴

if(string1.toUpperCase() == string2.toUpperCase())

使用带有忽略大小写选项的正则表达式匹配器

var regEx=new RegExp('abc','i');
console.log(regEx.test('Abc'));
console.log(regEx.test('ABC'));

console.log(regEx.test('AAA')您知道您正在使用对regexp的隐式转换,并且没有转义特殊字符吗?您确定不只是想要
text.toLowerCase().indexOf(searchTerm.toLowerCase())
if(string1.toUpperCase() == string2.toUpperCase())