Javascript 如何从Jquery数据表对fnFilter中的多个值进行正则表达式匹配?

Javascript 如何从Jquery数据表对fnFilter中的多个值进行正则表达式匹配?,javascript,jquery,regex,datatables,Javascript,Jquery,Regex,Datatables,Im正在尝试使用Jquery datatable中的多个值进行筛选,但正则表达式失败 这项工作: // $(this).val()[0] = "Testing string"; test.fnFilter("^" + $(this).val()[0] + "$", i, true, true); This filters all the rows to value "Testing string" for this column. 但当我尝试对多个值执行此操作时,它无法正常工作: // i

Im正在尝试使用Jquery datatable中的多个值进行筛选,但正则表达式失败

这项工作:

// $(this).val()[0] = "Testing string";

test.fnFilter("^" + $(this).val()[0] + "$", i, true, true);

This filters all the rows to value "Testing string" for this column.
但当我尝试对多个值执行此操作时,它无法正常工作:

// inputValues = "(Testing string|Hello world)"

dossierlijst.fnFilter("^" + inputValues + "$", i, true, true);
“(测试字符串)|(Hello world)”做什么?
我自己也非常依赖正则表达式。因为这会吃掉两个组,也许JS不喜欢括号在外面?

解决方案是在每个值前面加^1,后面加$2

// inputValues = "(^Testing string$)|(^Hello world$)"

dossierlijst.fnFilter(inputValues, i, true, true);

这应该作为对问题的评论,而不是回答。哎呀,我的错。我能换一下吗?此外,我还不能发表评论,我需要50%的声誉;“^(测试字符串)|(Hello world)$”仅过滤您编写的问题中“测试字符串”上的行
”(“测试字符串| Hello world)”
fnFilter
函数调用中添加
^
$
。这与
(^Testing string$)|(^Hello world$)
的功能完全匹配。它只是以不同的方式捕捉。所以肯定还有其他变量(在
fnFilter
中)。