未捕获的SyntaxError:无效的正则表达式:/ (^ |\。)dt(\。| $)/:yajra数据表中的堆栈溢出错误

时间:2017-09-18 11:56:01

标签: laravel datatable

当我重新初始化yajra datatable时,我收到此错误 未捕获的SyntaxError:无效的正则表达式:/ (^|。)dt(。| $)/:堆栈溢出

可能是什么原因。

1 个答案:

答案 0 :(得分:0)

如果正则表达式确实是/(^|.)dt(.|$)/:,那么结尾:在javascript中效果不佳,正则表达式应该以{{1​​}}开头和结尾。

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

唯一允许的选项是 g m i y y (在最后/之后):  https://regex101.com/r/l7mwwt/1

/

enter image description here

如果你有任何机会想要匹配const regex = /(^|.)dt(.|$)\/:/gmiuy; const str = ``; let m; while ((m = regex.exec(str)) !== null) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { regex.lastIndex++; } // The result can be accessed through the `m`-variable. m.forEach((match, groupIndex) => { console.log(`Found match, group ${groupIndex}: ${match}`); }); } litteral你应该逃避斜线