日期:2014-05-16 浏览次数:20450 次
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title></title> </head> <body> <textarea id="str"> 12312312312312<br/> 1231asdfasdf<br/><br/><br/> aSVdikagisdgviasdgi<br/><br/><br/><br/><br/> asbgdiahsod<br/><br/><br/> </textarea> <script> function $(el){ return typeof el == 'string' ? document.getElementById(el) : el; } var s = $('str').value; var r = /[^\s]+/g; var tmp = /<.+(?=<br\/>$)/g //alert( s.match(r) ) s = s.replace(r, function($){ return $.replace(tmp, ''); }) alert(s) </script> </body> </html>