蛙蛙推荐:用VBS写了一个字符串实用函数的类
来源:互联网 发布:防止xss攻击php 编辑:程序博客网 时间:2024/05/18 20:46
<!-- 蛙蛙推荐:用VBS写了一个字符串实用函数的类,不知道实用不实用 -->
<%
Class wawa_str '创建一个名为wawa的类
'*********************************************************
' 目的:字符串实用函数,每个方法做了相应的注释,我没有用正则表达式来判断要
' 搜索字符串的边界,只是简单了写了一下函数,如果要判断边界的话要用/b,
' 主要是vbs的政则表达式不好用,所以就没写,下次有时间再把这个类完善一下
' 并把它改写成C#版本的
' 作者:天极.蛙蛙王子
' 变量:WawaValue(私有变量)
' 属性:
' 方法:
'*********************************************************
private WawaValue '创建一个内部私有变量
Private Sub Class_Initialize() '定义类的初始化事件
End Sub
Private Sub Class_Terminate ' 设置 Terminate 事件。 '定义类的清空事件
End Sub
Public Property Let propertywawa(ByVal wawa_arg) '定义类的一个let属性
WawaValue=wawa_arg
End Property
Public Property Get propertywawa() '定义一个类的get属性
propertywawa=WawaValue
End Property
Public Function GetFront(ByVal mainStr,ByVal searchStr ) '获取要搜索字符串左边的字符
dim FoundOffset
FoundOffset=instr(mainStr,searchStr)
If FoundOffset=1 Then
getfront= ""
End If
getfront= mid(mainStr,1,foundoffset-1)
End Function
Public Function getend(ByVal mainStr,ByVal searchStr ) '获取要搜索字符串右边的字符
dim FoundOffset
FoundOffset=instr(mainStr,searchStr)
If FoundOffset=1 Then
getend= null
End If
getend=mid(mainstr,len(searchstr)+1)
End Function
Public Function insertString(ByVal mainStr,ByVal searchStr,ByVal insertStr ) '在要搜索的字符串前插入一个字符串
dim front,endwawa
front=getfront(mainstr,searchstr)
endwawa=getend(mainstr,searchstr)
insertstring=(front&insertstr&endwawa)
End Function
Public Function deleteString(ByVal mainStr,ByVal deletestr) '删除要搜索的字符串
deletestring=replace(mainstr,deletestr,"")
End Function
Public Function replaceString(ByVal mainStr,ByVal searchstr,ByVal replacestr) '替换要搜索的字符串
dim front,endwawa
front=getfront(mainstr,searchstr)
endwawa=getend(mainstr,searchstr)
replacestring=(front&replacestr&endwawa)
End Function
End Class
set temp=new wawa_str
response.write(temp.getfront("hellowawa","wawa"))
response.write("<br>")
response.write(temp.getend("wawabyebye","wawa"))
response.write("<br>")
response.write(temp.insertstring("tianwawa","wawa","cai"))
response.write("<br>")
response.write(temp.deletestring("wawatiancai","wawa"))
response.write("<br>")
response.write(temp.replacestring("wawatiancai","wawa","hello"))
response.write("<br>")
'response.write("<br>")
%>
- 蛙蛙推荐:用VBS写了一个字符串实用函数的类
- 蛙蛙推荐:写了个一个vbs类的模板
- 蛙蛙推荐:vbs调用js函数
- AS3写的一个HashMap类,非常实用,收集了!
- 蛙蛙推荐:VBS的数据库操作类,
- 推荐一个比较好的VBS编辑器
- 写了一个简单实用的PHP模板引擎
- 写了几个实用的JS函数,记录下。
- 用js写了一个判断矩形相交的函数
- 写一个函数,实现字符串的复制
- 用java写了一个实用的类----递归的拷贝给定目录的.java文件到指定的一个文件中
- 蛙蛙推荐:刚写了一个开发计划,大家给提些意见
- vbs计算字符串在一个文本中出现次数的函数
- 手把手地写了一个函数,计算出两个字符串日期之间的所有字符串型日期 集合
- vbs--- 字符串函数
- vbs 字符串函数
- 蛙蛙推荐:刚刚写了一个考试程序,给大家贴一下,我没写过多注释哦
- 写一个函数,求一个字符串的长度。
- 70年代生人的黄金拼图
- 辽东满族望族八大姓氏探源
- 蛙蛙推荐:巧用缓存提高asp程序的性能
- 蛙蛙推荐:写了个一个vbs类的模板
- 蛙蛙推荐:asp中常用的数据库连接页面
- 蛙蛙推荐:用VBS写了一个字符串实用函数的类
- 蛙蛙推荐:asp中getrows的用法
- The Java Programming Language Notes
- 实现聊天室无刷新的JavaScript技术
- 蛙蛙推荐:把recordset保存成xml文件
- 不太好玩
- SQL
- DUPLICATION 今天7.7事变。
- 我的第一个blog留言:CDT新版出来了!