去掉字符串中間空格的方法

来源:互联网 发布:ubuntu拼音输入法无效 编辑:程序博客网 时间:2024/06/05 11:24
Function xuankong(str)Dim resultDim jj=len(str)result=""Dim iFor i=1 To j Select Case mid(str,i,1) Case ""<"" result=result+""<"" Case "">"" result=result+"">"" Case chr(34) result=result+"" Case ""&"" result=result+""&""'以上代???一些html??  Case chr(255)'防止特殊空格 result=result Case chr(13)'防止回?符 result=result+""Case chr(32)'防止?行符  result=result+"" Case Else result=result+mid(str,i,1) End SelectNextxuankong=resultEnd Function這個是ASP實現,思路可用於JSPpublic String filterHtml(String value){value=value.replaceAll("&","&");value=value.replaceAll("<","<");value=value.replaceAll(">",">");value=value.replaceAll(" "," ");value=value.replaceAll("'","'");value=value.replaceAll("/"",""");value=value.replaceAll("/n","
");}在頁面中 string temp=filterHtml(request.getParameter(temp));
原创粉丝点击