ASP中读取数据库内容时如何去掉空格,也就是
<%=left(rs("xx"),34)%>我是这样读取的,我要去掉所有的空格而且读取一定字数以内的内容...
<%=left(rs("xx"),34)%>我是这样读取的,我要去掉所有的空格而且读取一定字数以内的内容
展开
8个回答
展开全部
<%=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
加上这个函数
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
加上这个函数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
trim(rs("str"))这个是去掉头尾的空格。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<%=left(replace(rs("xx")," ","")),34)%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
str = replace(str," ","")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询