去掉字符串中間空格的方法
2010-05-06 18:18
225 查看
Function xuankong(str)
Dim result
Dim j
j=len(str)
result=""
Dim i
For 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 Select
Next
xuankong=result
End Function
這個是ASP實現,思路可用於JSP
public 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));
Dim result
Dim j
j=len(str)
result=""
Dim i
For 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 Select
Next
xuankong=result
End Function
這個是ASP實現,思路可用於JSP
public 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));
相关文章推荐
- PHP中去掉字符串首尾空格的方法
- js去掉字符串前后空格的五种方法
- 去掉一段字符串前后空格得五种方法
- js去掉字符串前后空格的五种方法
- c#中去掉字符串空格方法
- js 去掉字符串前后空格5种方法
- string类的GetCharEnumerator方法去掉字符串中空格
- jQuery trim() 方法去掉字符串的前后空格
- python几种去掉字符串中间空格的方法
- 20141014个人日志(ios 字符串轻易去掉空格的方法)
- jQuery去掉字符串起始和结尾的空格(多种方法实现)
- Python去掉字符串中空格的方法
- 去掉字符串连续多个空格的方法
- 在objective-c中去掉字符串前后空格的方法
- [Java]去掉字符串中空格的几种方法
- ASP.NET C# 去掉字符串中间空格方法
- String的trim()方法如何去掉字符串中前/后面的空格
- js去掉字符串前后空格的五种方法
- c#字符串去掉空格的二种方法(去掉两端空格)
- c#中去掉字符串空格方法