主页 > 知识库 > asp 字符串截取函数

asp 字符串截取函数

热门标签:福建外呼增值业务线路 伊春外呼业务系统 调度系统外呼 宜宾语音外呼系统软件 河北智能外呼系统软件 绵阳防封电销卡价格 电销机器人教育 电销机器人源码网盘下载 中国办理电信400电话
asp 字符串截取函数
'*********************************************************
'函数:cutStr[str(strlen)]
'参数:str,待处理的字符串,strlen,截取的长度
'作者:木木
'日期:2007/7/12
'描述:截取指定长度的字符串
'示例:%=cutStr("欢迎光临阿里西西",5)%>

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

function cutStr(str,strlen)
 If str = "" Then
 cutStr = "cutStr函数异常:字符串为空"
 exit function
 End If
'------------来源长度检查
 If  strlen = "" Then
 cutStr = "cutStr函数异常:长度未指定"
 exit function
 End If 

 If  CInt(strlen) = 0 Then
 cutStr = "cutStr函数异常:长度为0"
 exit function
 End If 
'----------检测来源字符长度
 dim l,t,c,i
 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
 cutStr=left(str,i)".."
 exit for
 else
 cutStr=str
 end if
 next
 cutStr=replace(cutStr,chr(10),"")
end function
''*********************************************************
'函数:strlen[str]
'参数:str,待处理的字符串
'作者:木木
'日期:2007/7/12
'描述:判断字符串长度,汉字长度为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个字符'*********************************************************
'函数:LeftTrue(str,n)
'参数:str,待处理的字符串,n,截取的长度
'作者:木木
'日期:2007/7/12
'描述:显示左边的n个字符(自动识别汉字)函数
'示例:%=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
  c=asc(mid(str,i,1))
  If c0 then c=c+65536
  If c>255 then
  t=t+2
  Else
  t=t+1
  End If
  If t>n Then exit for
  TStr=TStr(mid(str,i,1))
 next
 LeftTrue = TStr
End If
End Function


您可能感兴趣的文章:
  • asp截取字符串的两种应用
  • asp下实现截取字符串特定部分内容函数
  • GetBody asp实现截取字符串的代码
  • 用asp实现的截取指定格式字符串的代码
  • asp从字符串里截取N个带HTML的字符的函数
  • asp截取指定英汉混合字符串_支持中文
  • ASP.NET 字符串截取
  • asp CutStrX字符串截取函数(过滤全部HTML标记)
  • asp实现截取字符串函数

标签:电商邀评 铜川 那曲 苏州 新乡 河池 延边 优质小号

巨人网络通讯声明:本文标题《asp 字符串截取函数》,本文关键词  asp,字符串,截取,函数,asp,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《asp 字符串截取函数》相关的同类信息!
  • 本页收集关于asp 字符串截取函数的相关信息资讯供网民参考!
  • 企业400电话

    智能AI客服机器人
    15000

    在线订购

    合计11份范本:公司章程+合伙协议+出资协议+合作协议+股权转让协议+增资扩股协议+股权激励+股东会决议+董事会决议

    推荐文章