ASP中读取数据库内容时如何去掉空格,也就是 

<%=left(rs("xx"),34)%>我是这样读取的,我要去掉所有的空格而且读取一定字数以内的内容

<%=left(trim(rs("xx")),34)%> 去掉头尾空格
<%=left(Rtrim(rs("xx")),34)%> 去掉尾空格
<%=left(Ltrim(rs("xx")),34)%> 去掉头空格
<%=left(replace(rs("xx")," ","")),34)%> 去掉所有空格
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-09-19
<%=nohtml(left(rs("xx"),34))%>

function nohtml(str)
if trim(str)<>"" then
dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern="(<.+?>)"
str=re.replace(str,"")
re.Pattern="(\<\/[^\<]*\>)"
str=re.replace(str," ")
str=replace(str," ","")
str = replace(str, " ", "")
str = Replace(str, CHR(32), "")
str = Replace(str, CHR(9), "")
str = Replace(str, CHR(34), "")
str = Replace(str, CHR(39), "")
str = Replace(str, CHR(13), "")
str = Replace(str, CHR(255), "")
str = Replace(str, CHR(10), "")
str = Replace(str, CHR(11), "")
str = Replace(str, CHR(12), "")
nohtml=str
set re=nothing
end if
end function

加上这个函数
第2个回答  2008-09-19
trim(rs("str"))这个是去掉头尾的空格。
第3个回答  2008-09-19
<%=left(replace(rs("xx")," ","")),34)%>
第4个回答  2008-09-19
str = replace(str," ","")
相似回答