Fix escaping of \ in character class.
> Rejeté. Ce n'est pas un escape. D’après mes tests, c’est considéré comme un escape. Doubler le caractère serait suffisant. const url = 'https://example\\.com'; const urlRegexp1 = /https?:\/\/[-a-zA-Z0-9@:%/._\+~#=?]+[-a-zA-Z0-9@:%/_\+~#=]/g; const urlRegexp2 = /https?:\/\/[-a-zA-Z0-9@:%/._\\+~#=?]+[-a-zA-Z0-9@:%/_\\+~#=]/g; console.log(url.length); // 20 console.log(urlRegexp1.exec(url)); // ["https://example"] console.log(urlRegexp2.exec(url)); // ["https://example\.com"]
Showing
Please register or sign in to comment