ASP指定字符截取字符串

ASP 1732 0 2013-02-16

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)
%>

上一篇:ASP上传文件时的错误:ASP 0104 : 80004005解决方法

下一篇:ASP过滤字符函数

讨论数量:0

请先登录再发表讨论。 2024-04-30

天涯网魂
3 杠 5 星
TA 的文章
TA 的随言
TA 的资源链