国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > ASP > 正文

asp 字符串截取函數(shù)

2024-05-04 11:01:19
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
asp 字符串截取函數(shù)
'*********************************************************
'函數(shù):cutStr[str(strlen)]
'參數(shù):str,待處理的字符串,strlen,截取的長(zhǎng)度
'作者:木木
'日期:2007/7/12
'描述:截取指定長(zhǎng)度的字符串
'示例:<%=cutStr("歡迎光臨阿里西西",5)%>

'*********************************************************

function cutStr(str,strlen)
 If str = "" Then
 cutStr = "cutStr函數(shù)異常:字符串為空"
 exit function
 End If
'------------來(lái)源長(zhǎng)度檢查
 If  strlen = "" Then
 cutStr = "cutStr函數(shù)異常:長(zhǎng)度未指定"
 exit function
 End If 

 If  CInt(strlen) = 0 Then
 cutStr = "cutStr函數(shù)異常:長(zhǎng)度為0"
 exit function
 End If 
'----------檢測(cè)來(lái)源字符長(zhǎng)度
 dim l,t,c,i
 l=len(str)
 t=0
'----------循環(huán)截取字符
 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
 '------判斷是否到達(dá)指定長(zhǎng)度
 if t>=strlen then
 cutStr=left(str,i)&".."
 exit for
 else
 cutStr=str
 end if
 next
 cutStr=replace(cutStr,chr(10),"")
end function
''*********************************************************
'函數(shù):strlen[str]
'參數(shù):str,待處理的字符串
'作者:木木
'日期:2007/7/12
'描述:判斷字符串長(zhǎng)度,漢字長(zhǎng)度為2
'示例:<%=strlen("歡迎光臨阿里西西")%>
'*********************************************************
Function strlen(str)
dim p_len
p_len=0
strlen=0
if trim(str)<>"" then
p_len=len(trim(str))
for xx=1 to p_len
if asc(mid(str,xx,1))<0 then
strlen=int(strlen) + 2
else
strlen=int(strlen) + 1
end if
next
end if
End Function
截取左邊的n個(gè)字符'*********************************************************
'函數(shù):LeftTrue(str,n)
'參數(shù):str,待處理的字符串,n,截取的長(zhǎng)度
'作者:木木
'日期:2007/7/12
'描述:顯示左邊的n個(gè)字符(自動(dòng)識(shí)別漢字)函數(shù)
'示例:<%=LeftTrue("歡迎光臨阿里西西",6)%>
'*********************************************************

Function LeftTrue(str,n)
If len(str)<=n/2 Then
 LeftTrue=str
Else
 Dim TStr
 Dim l,t,c
 Dim i
 l=len(str)
 t=l
 TStr=""
 t=0
 for i=1 to l
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 汶川县| 醴陵市| 光泽县| 措美县| 香河县| 贡山| 卢氏县| 鄂伦春自治旗| 通化市| 嘉峪关市| 松阳县| 陈巴尔虎旗| 同江市| 沁源县| 合阳县| 普洱| 子长县| 鄂托克前旗| 凤翔县| 卢湾区| 金堂县| 阿克陶县| 新丰县| 怀柔区| 泗水县| 赤水市| 米脂县| 吉木萨尔县| 巴里| 云和县| 土默特左旗| 正镶白旗| 东乌珠穆沁旗| 博客| 肥城市| 乐陵市| 当阳市| 灵山县| 那坡县| 莆田市| 冀州市|