且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

javascript正则表达式评估导致浏览器挂起

更新时间:2021-10-16 22:15:26

尝试将([-+.]*[\w-]+)*替换为([-.]\w+)*

^\w+([-.]\w+)*@\w+([-.]\w+)*\.\w{2,4}$

您可以在此处找到有关灾难性回溯的更多信息.

You can find more informations about catastrophic backtracking here.

第二种模式也可能导致灾难性的回溯,因为点可以与文字点和arobase相匹配.

The second pattern can cause a catastrophic backtracking too since the dot can match the literal dot, and the arobase.

请注意,这种模式非常基础,并且会排除许多格式正确的电子邮件地址.

Note that this kind of pattern is very basic and will exclude many well formed email addresses.