标题:截取字符函数
只看楼主
chenxiang
Rank: 1
等 级:新手上路
帖 子:38
专家分:0
注 册:2007-3-14
 问题点数:0 回复次数:3 
截取字符函数
if len(trim(rs("anclass")))>5 then
response.write left(trim(rs("anclass")),5)&".."
else
response.write trim(rs("anclass"))
end if
每次截取字符串的时候总象上述方法这么麻烦,请问各位大虾有没有更简单的方法,比如ASP是否有函数可以截取
搜索更多相关主题的帖子: 函数 字符 
2007-08-19 18:24
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
得分:0 
这还算麻烦?

你自己写个函数吧


也可以你rs在存的时候就做好Trim工作
2007-08-19 18:29
ayue222
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:341
专家分:0
注 册:2007-7-25
得分:0 
function gotTopic(str,strlen)
if str="" or IsNull(str) then
gotTopic=""
exit function
end if
dim l,t,c, i
str=replace(replace(replace(replace(str,"&nbsp;"," "),"&quot;",chr(34)),"&gt;",">"),"&lt;","<")
l=len(str)
t=0
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
gotTopic=left(str,i)
exit for
else
gotTopic=str
end if
next
gotTopic=replace(replace(replace(replace(gotTopic," ","&nbsp;"),chr(34),"&quot;"),">","&gt;"),"<","&lt;")
end function

汉字、英文都算做一个字符的函数。。。
2007-08-19 22:32
craft001wen
Rank: 2
等 级:论坛游民
帖 子:242
专家分:62
注 册:2006-5-4
得分:0 
这算很简单的了

2007-08-20 08:33



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-163914-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.486487 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved