罗马的房子迅雷种子:asp截取字符问题!急!都进来看看!

来源:百度文库 编辑:中科新闻网 时间:2024/04/28 12:19:05
中华人民共和国于1949年10月1日成立了
我承认中华人民共和国的确强大

上面2个句子,如果我只想让它显示前10个字符,后面的字符都是...

应该怎么弄?用什么代码?谢谢!(ASP代码)

<%
str1=中华人民共和国于1949年10月1日成立了
str2=我承认中华人民共和国的确强大

'下面是新得到得字符串
newstr1=str_jq(str1)
newstr2=str_jq(str2)

function str_jq(str)
if len(str)>10 then
str_jq=left(str,10) & "…"
else
str_jq=str
end if
end function

%>

dim a
a="中华人民共和国于1949年10月1日成立了我承认中华人民共和国的确强大"
left(a,10)
如果加上判断的话
if len(a)>10 then
response.write ""&left(a,10)&"&.."
else
response.write ""&a&""
end if
以上是超过长度用..代替!

function cutstr(tempstr,tempwid)
if len(tempstr)>tempwid then
cutstr=left(tempstr,tempwid)&"..."
else
cutstr=tempstr
end if
end function

参数tempstr是要截取的字符串 参数tempwid是要截取多长的数据

先取得字符(假如那个句子是a)
a=rs("a")


<%=left("a,10)%>...

中华人民共和国于19...

left("中华人民共和国于1949年10月1日成立了",10)&"..."