2017-09-18 15 views
0

當我重新初始化yajra數據表時,出現此錯誤 未捕獲的SyntaxError:無效的正則表達式:/(^|.)dt(.|$)/:堆棧溢出

可能是什麼原因。

+0

它可能與此有關,但是你可以在什麼時間和地點發生什麼? https://laravel.com/docs/5.5/validation#rule-regex – Loek

回答

0

如果正則表達式確實是/(^|.)dt(.|$)/:那麼尾隨:在javascript中不好,那麼正則表達式應該以/開始和結束。

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

唯一允許的選項是克米I UÝ(最後/後): 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}`); 
 
    }); 
 
}

enter image description here

如果你想要匹配/: litteral,你應該逃脫你的斜線