移除回车换行等字符

转自:http://dev.mjxy.cn/a-Javascript-Remove-control-character-from-string.aspx

// Remove control character from a string

function removeNL(s)
{
     // NewLine, CarriageReturn and Tab characters from a String
     // will be removed and will return the new string

     r = "";
     for (i = 0; i < s.length; i++)
     {
         if (s.charAt(i) != '\n' & s.charAt(i) != '\r' & s.charAt(i) != '\t') {
             r += s.charAt(i);
         }
     }

     return r;
}

posted @ 2011-07-08 15:36  敏捷学院  阅读(248)  评论(0编辑  收藏  举报