截取实际长度字符串,并用空格替换
2006-06-20 00:00
363 查看
function cutstr(thestr,strlen)
dim l,t,c
l=len(thestr)
t=0
for dxy=1 to l
c=Abs(asc(Mid(thestr,dxy,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
thev=left(thestr,dxy)
exit for
else
bu=strlen-t
for bui=1 to bu
strbu=" "
strbuall=strbuall&strbu
next
thev=thestr&strbuall
strbu=""
strbuall=""
end if
next
cutstr=thev
end function
<%
'============================
'函数名w_cut(type,num)
'作用:字符串截取
'参数type,num
'type:字符串内容
'num:字符串被截取的长度
'=============================
Function w_cut(types,num)
dim ctypes,cnum,ci,tt,tc,cc
ctypes=types:cnum=int(num):w_cut="":tc=0:cc=0
for ci=1 to len(ctypes)
if cnum<0 then w_cut=w_cut&"...":exit for
tt=mid(ctypes,ci,1)
if int(asc(tt))>=0 then
w_cut=w_cut&tt
tc=tc+1:cc=cc+1
if tc=2 then
tc=0:cnum=cnum-1
end if
if cc>5 then cnum=cnum-1:cc=0
else
cnum=cnum-1
if cnum<=0 then w_cut=w_cut&"...":exit for
w_cut=w_cut&tt
end if
next
End Function
%>
dim l,t,c
l=len(thestr)
t=0
for dxy=1 to l
c=Abs(asc(Mid(thestr,dxy,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
thev=left(thestr,dxy)
exit for
else
bu=strlen-t
for bui=1 to bu
strbu=" "
strbuall=strbuall&strbu
next
thev=thestr&strbuall
strbu=""
strbuall=""
end if
next
cutstr=thev
end function
<%
'============================
'函数名w_cut(type,num)
'作用:字符串截取
'参数type,num
'type:字符串内容
'num:字符串被截取的长度
'=============================
Function w_cut(types,num)
dim ctypes,cnum,ci,tt,tc,cc
ctypes=types:cnum=int(num):w_cut="":tc=0:cc=0
for ci=1 to len(ctypes)
if cnum<0 then w_cut=w_cut&"...":exit for
tt=mid(ctypes,ci,1)
if int(asc(tt))>=0 then
w_cut=w_cut&tt
tc=tc+1:cc=cc+1
if tc=2 then
tc=0:cnum=cnum-1
end if
if cc>5 then cnum=cnum-1:cc=0
else
cnum=cnum-1
if cnum<=0 then w_cut=w_cut&"...":exit for
w_cut=w_cut&tt
end if
next
End Function
%>
相关文章推荐
- asp.net 将指定字符串按指定长度进行截取并用其他字符串替换方法
- asp.net在前台将指定字符串按指定长度进行截取并用其他字符串替换方法
- excel函数应用练习---判断字符串长度,去掉字符串里的空格,全角句号替换为小数点
- 字符串空格替换、合法括号序列判断、最长无重复子串长度
- 字符串操作去空格,替换,截取
- linux shell 字符串操作详解 (长度,读取,替换,截取,连接,对比,删除,位置 )
- linux shell 字符串操作详解 (长度,读取,替换,截取,连接,对比,删除,位置 )
- String字符串操作--切割,截取,替换,查找,比较,去空格.....
- NSString:创建,长度,取字符,是否以某字符串开头,结尾, 查找指定字符串的范围,截取,拼接,替换,比较,替换,数值转换,大小写转换
- 字符串实际长度及其根据实际长度截取的问题
- linux shell 字符串操作详解 (长度,读取,替换,截取,连接,对比,删除,位置 )
- 字符串的判断;截取;去空格;查找替换和分割以及大小写转换
- DOS命令(cmd)批处理:替换字符串、截取字符串、扩充字符串、获取字符串长度
- [No0000A4]DOS命令(cmd)批处理:替换字符串、截取字符串、扩充字符串、获取字符串长度
- 批处理:替换字符串、截取字符串、扩充字符串、获取字符串长度
- c#中取字符串实际长度和截取数据组
- 替换字符串中的空格&求字符串最后一个单词的长度
- perl中操作mysql,字符匹配与替换,字符串截取,计算字符长度
- 请编写一个方法,将字符串中的空格全部替换为“%20”。假定该字符串有足够的空间存放新增的字符,并且知道字符串的真实长度(小于等于1000),同时保证字符串由大小写的英文字母组成。 给定一个string