var haystack = " he she they you we yours us ALL OURS";
var needle = "he she ours";
我想比较string needle和string haystack,忽略大小写,以确定needle是否是haystack的子串容器。 请建议。
答案 0 :(得分:0)
一个字符串变量作为其他忽略大小写的子字符串
您可以执行此操作以忽略大小写
if (list.toLowerCase().indexOf(t.toLowerCase()) >= 0) { ... }
或
var regex = new RegExp(t, 'i'); // i = ignore case
if (regex.test(list)){ ... }