从TSYS通用函数库中提取出了一些有用的函数
来源:互联网 发布:path finder for mac 编辑:程序博客网 时间:2024/04/29 22:05
<%
'函数:过滤Html标签
'参数:字符串
'返回:过滤后字符串
Public Function FilterHtml(str)
Dim regEx
'创建正则对象
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
regEx.MultiLine = True
regEx.Pattern = "<.+?>"
FilterHtml = regEx.Replace(str,"")
Set regEx = Nothing
End Function
'函数:验证邮件地址格式
'参数:字符串
'返回:bool (true:正确)
Public Function CheckEmail(str)
Dim regEx
'创建正则对象
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
regEx.MultiLine = True
regEx.Pattern = "^/w+((-/w+)|(/./w+))*/@[A-Za-z0-9]+((/.|-)[A-Za-z0-9]+)*/.[A-Za-z0-9]+$"
CheckEmail = regEx.Test(str)
Set regEx = Nothing
End Function
'函数:是否为服务实际路径
Public Function IsReallyPath(str)
Dim regEx
'创建正则对象
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
regEx.MultiLine = True
regEx.Pattern = "^[c-z]/:.+$"
IsReallyPath = regEx.Test(str)
Set regEx = Nothing
End Function
'函数:判断路径类型
'返回:
' 1 物理路径
' 2 站点虚路径
' 3 网络路径
Public Function ChkPathType(strPath)
Dim regEx
'创建正则对象
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
regEx.MultiLine = False
regEx.Pattern = "^[c-z]{1,1}/:.+$"
If regEx.Test(strPath) Then
ChkPathType = 1
Exit Function
End If
regEx.Pattern = "^(?:http|https){1,1}/:.+$"
If regEx.Test(strPath) Then
ChkPathType = 3
Exit Function
End If
ChkPathType = 2
Set regEx = Nothing
End Function
'函数:字符串截断(可识别中英文)
'参数:预截字符串,长度
'返回:截断后的字符串
Public Function CutStr(str,strlen)
DIM l,t,c,m_i
l=len(str)
t=0
For m_i = 1 To l
c = Abs(Asc(Mid(str,m_i,1)))
If c > 255 Then
t = t+2
Else
t = t+1
End If
If t >= strlen Then
CutStr = left(str,m_i) & "..."
exit for
Else
CutStr = str
End if
Next
End Function
'函数:转义javascript特殊字符
'参数:html串
'返回:转义后的串
Public Function HTMLToJS(strHtml)
If Trim(strHtml)="" Then
HTMLToJS=""
Exit Function
End If
strHtml=Replace(strHtml,"/","//")
strHtml=Replace(strHtml,"""","/""")
strHtml=Replace(strHtml,vbCrLf,"")
HTMLToJS=strHtml
End Function
'函数:时间格式化
'参数:时间,格式模板
'返回:格式化后的字符串
'备注:格式化关键词详解:
' "{Y}" : 4位年
' "{y}" : 2位年
' "{M}" : 不补位的月
' "{m}" : 补位的月,如03,01
' "{D}" : 不补位的日
' "{d}" : 补位的日
' "{H}" : 不补位的小时
' "{h}" : 补位的小时
' "{MI}": 不补位的分钟
' "{mi}": 补位的分钟
' "{S}" : 不补位的秒
' "{s}" : 补位的秒
Public Function FormatMyDate(myDate,Template)
If Not IsDate(myDate) Or Template = "" Then
FormatMyDate = Template
Exit Function
End If
Dim mYear,mMonth,mDay,mHour,mMin,mSec
mYear = Year(myDate)
mMonth = Month(myDate)
mDay = Day(myDate)
mHour = Hour(myDate)
mMin = Minute(myDate)
mSec = Second(myDate)
Template = Replace(Template,"{Y}",Year(myDate))
Template = Replace(Template,"{y}",Right(Year(myDate),2))
Template = Replace(Template,"{M}",Month(myDate))
Template = Replace(Template,"{m}",Right("00" & Month(myDate),2))
Template = Replace(Template,"{D}",Day(myDate))
Template = Replace(Template,"{d}",Right("00" & Day(myDate),2))
Template = Replace(Template,"{H}",Hour(myDate))
Template = Replace(Template,"{h}",Right("00" & Day(myDate),2))
Template = Replace(Template,"{MI}",Minute(myDate))
Template = Replace(Template,"{mi}",Right("00" & Minute(myDate),2))
Template = Replace(Template,"{S}",Second(myDate))
Template = Replace(Template,"{s}",Right("00" & Second(myDate),2))
FormatMyDate = Template
End Function
'函数:通用信息提示框
'参数:
' 提示内容
' 返回地址,详细值类型如下:
' "#" 只提示,其它不做任何操作
' "BACK" 提示后返回前一页
' "CLOSE" 提示后关闭窗口
' "网址" 提示后返回指定页面
' 是否父窗口
Public Function Alert(str,backUrl,TopWindow)
If str <> "" Then
Response.Write "<script>alert(""" & str & """);"
End If
Dim WinName
If TopWindow = 1 Then
WinName = "top"
Else
WinName = "self"
End If
Select Case backUrl
Case "#"
Case "BACK"
Response.Write WinName & ".history.back();"
Case "CLOSE"
Response.Write "window.close();"
Case Else
If backUrl <> "" Then
Response.Write WinName & ".location.href = """ & backUrl & """;"
End If
End Select
Response.Write "</script>"
End Function
'函数:创建完整目录
'参数:目录串
Public Function CreateFolder(strPath)
strPath = Replace(strPath,"/", "/")
arrPath = Split(strPath, "/")
Dim Fso, I, tmpPath, arrPath
Set Fso = Server.CreateObject(Cfg.FileSystemObject_Name)
tmpPath = arrPath(0)
For I=1 To UBound(arrPath)
tmpPath = tmpPath & "/" & arrPath(I)
If Not Fso.FolderExists(tmpPath) Then
Fso.CreateFolder tmpPath
End If
Next
End Function
Public Function FormatEmpty(str, fstr)
If IsNull(str) Or str = "" Then
FormatEmpty = fstr
Else
FormatEmpty = str
End If
End Function
%>
- 从TSYS通用函数库中提取出了一些有用的函数
- 从zImage中提取出Image的方法
- XPATH中一些有用的函数
- numpy函数库中一些常用函数的记录
- 从TSPLib中提取出邻接矩阵
- 从string中提取出数字
- 从字符串中提取出汉字?
- 从字符串中提取出数字
- 一些有用的函数
- 一些有用的函数
- 一些有用的函数
- 一些有用的函数
- 从字符串中提取单词、从字符串中提取汉字的函数
- 机器学习中,从一张图片中提取出感兴趣的区域(以交通标志为例)
- 如何从txt中或者codeblocks中提取出某一列的数值
- 一些有用的wap函数
- 一些有用的asp函数
- 一些有用的时间函数
- 关于BLOG和WIKI的苦恼
- Fibonacci 单词
- 4月30日 晴
- Office Execl 操作方法
- C专家编程--学习笔记(1)_为什么程序员分不清万圣节和圣诞节
- 从TSYS通用函数库中提取出了一些有用的函数
- 一个C#睡前故事
- 回忆4个故事
- 男人25岁前的忠告
- .Net下调用SqlServer2k中存储过程
- webcontrol中的collection属性
- 改变一生的五句话
- Proxy Server
- 使用设计模式改善程序结构(一)