0
我已经使用脚本删除双空间。但是这个脚本也将随着空间一起删除新行。删除双空间,但不是新线
Suppose Input is "\s\s\n\n" Script's output is "\s" Desired Output "\s\n\n" That I simply want to remover double space but not new line. Want to skip new line.
function clean(f) { f.value=f.value.replace(/^\s+|\s+$/g,'').replace(/\s\s+/g,' '); return true; }
'\ s'匹配'\ t \ n符\ v \˚F\ r'。 https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp#endnote_equivalent_s – 2011-03-26 06:21:22
'\ s'是任何[空格字符(参见字符转义部分)](http://www.javascriptkit.com /javatutors/redev2.shtml),包括换行符,制表符,垂直制表符,换行符等以及''''。 – jswolf19 2011-03-26 06:23:14