ASP指定字符截取字符串

程序代码 程序代码
<%
'*******************************************
'指定字符截取字符串
'in_str 要截取的字符串
'in_point 指定的字符,如:"/",".","|"
'in_type 截取类型,如:1截取前缀,2截取后缀,3截取后并换行
'*******************************************
Function intercept_str(in_str,in_point,in_type)
On Error Resume Next
Select Case in_type
Case 1
   intercept_str=left(in_str,instr(in_str,""&in_point&"")-1)
Case 2
   intercept_str=mid(in_str,instrRev(in_str,""&in_point&"")+1)
Case 3
   a = Split(in_str,""&in_point&"")
   For i = 0 To UBound(a)
      intercept_str=intercept_str&(a(i)&"<br>")
      Next
Case else
   intercept_str="截取失败,无效的截取类型,请检查参数是否正确!"
End Select
If Err Then Err.Clear: intercept_str="字符串截取失败,请检查指定截取的字符是否正确!"
End Function
strURL ="11111|22222|333333"
response.write intercept_str(strURL,"|",3)
%>



文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.