ASP指定字符截取字符串
作者:winxml 日期:2010-07-15
程序代码<%
'*******************************************
'指定字符截取字符串
'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)
%>
'*******************************************
'指定字符截取字符串
'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)
%>
评论: 0 | 引用: 0 | 查看次数: -
发表评论
上一篇
下一篇

文章来自:
Tags: