var text = '"window.alert(\"SPEED \");\n\nwindow.alert(\"SPEED \");\n\nwindow.alert(\"SPEED \");\n"';
var arr_f = text.replace(/^\\n$/g,'')
console.log(arr_f);
我这样写是,但是n都被执行了。打印出来是这样的
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
var arr_f = text.replace(/\n/g,'')