几个ASP字符串处理函数
作者:eisn 来源:51js 时间:2008-04-23 12:55:00
偶写的几个ASP字符串处理函数,用于文章分页的小玩意
函数名:StrLen
作 用:取得字符串长度(汉字为2)
参 数:str ----字符串内容
返回值:字符串长度
Function StrLen(Str)
Set rep = New regexp
rep.Global = True
rep.IgnoreCase = True
rep.Pattern = "[^\x00-\xff]"
StrLen = Len(Str) + rep.Execute(Str).Count
Set Rep = Nothing
End Function
函数名:StrLeft
作 用:从左面取指定数量字符串(汉字为2)
参 数:L ----字符个数
返回值:字符串
Function Strleft(Str, L)
Dim I, Test_Str, lens, tStr, nStr, tL
tStr = Left(Str, - Int( - (L / 2)))
nStr = Right(Str, Len(Str) - Len(tStr))
If Len(nStr)>0 Then tL = L - StrLen(tStr)
If Asc(Left(tStr, 1))<0 And Len(tStr) = 1 And L<2 Then tStr = ""
If tL>= 1 Then
Strleft = tStr&Strleft(nStr, tL)
Else
Strleft = tStr
End If
End Function
函数名:StrRight
作 用:从右面取指定数量字符串(汉字为2)
参 数:L ----字符个数
返回值:字符串
Function StrRight(Str, L)
Dim I, Test_Str, lens, tStr, nStr, tL
tStr = Right(Str, - Int( - (L / 2)))
nStr = Left(Str, Len(Str) - Len(tStr))
If Len(nStr)>0 Then tL = L - StrLen(tStr)
If Asc(Left(tStr, 1))<0 And Len(tStr) = 1 And L<2 Then tStr = ""
If tL>= 1 Then
StrRight = StrRight(nStr, tL)&tStr
Else
StrRight = tStr
End If
End Function
函数名:StrMid
作 用:指定开始位置取指定数量字符串(汉字为2)
参 数:S----开始字符串为第几个,L ----字符个数
返回值:字符串
Function StrMid(Str, S, L)
StrMid = strleft(Right(Str,Str Len(Str) - Len(strleft(Str, s)) + 1), L)
End Function
中文字符占两格英文是一格所以 要想分的整齐点就得这么干喽。
网上也有类似程序但没我的快的, 大家评评!
标签:字符串,函数,asp
0
投稿
猜你喜欢
页面编码的doctype声明
2007-05-31 09:21:00
Sql Server查询性能优化之不可小觑的书签查找介绍
2012-05-22 18:24:53
网页设计趋势之:”勾引”用户的按钮
2009-02-17 12:09:00
SQL查询效率注意事项小结
2012-01-05 19:31:25
Persits AspJpeg 1.8+ 轻松实现透明文字去锯齿水印
2009-03-20 14:03:00
oracle 分页 很棒的sql语句
2009-07-02 11:44:00
IE对CSS样式表的限制和解决方案
2008-04-28 12:27:00
div + ajax + 分页函数
2009-10-18 11:28:00
MYSQL教程:查询优化之有效加载数据
2009-02-27 15:45:00
使用javascript修复浏览器中12个常见而又头痛的问题
2008-10-28 19:38:00
BluePrint CSS框架0.9版发布
2009-06-03 21:02:00
asp 动态数组 提供Add、Insert、Remove、RemoveAt、Search等方法。
2011-03-17 11:10:00
asp动态页面防采集的新方法
2011-02-26 10:44:00
如何捕获人家站点的页面?
2009-11-11 19:19:00
Firebox 3 后退后按钮 diasabled 状态不恢复的一个解决方案
2008-11-06 12:28:00
10分钟学会Google Map API (一)
2009-06-07 18:17:00
鼠标经过超链时的提示图层源码
2010-03-17 20:51:00
oracle 常用的几个SQL
2009-12-01 12:36:00
讲解设计应用程序时避免阻塞的八个准则
2009-01-04 14:16:00
分析SQL Server中数据库的快照工作原理
2009-01-19 14:03:00