当我重新初始化yajra datatable时,我收到此错误 未捕获的SyntaxError:无效的正则表达式:/ (^|。)dt(。| $)/:堆栈溢出
可能是什么原因。
答案 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
/
如果你有任何机会想要匹配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你应该逃避斜线