当前位置: 网学 > 编程文档 > ASP > 正文

newasp中main类

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/17
'参 数:Str ----原字符串
'' PatStr ----符合条件字符
''================================================
Public Function CutMatchContent(ByVal str, ByVal start, ByVal last, ByVal Condition)

Dim Match,s,re
Dim FilterStr,MatchStr
Dim strContent,ArrayFilter
Dim i, n,bRepeat

If Len(start) = 0 Or Len(last) = 0 Then Exit Function

On Error Resume Next

MatchStr = "(" & CorrectPattern(start) & ")(.+?)(" & CorrectPattern(last) & ")"

Set re = New RegExp
re.IgnoreCase = True
re.Global = True
re.Pattern = MatchStr
Set s = re.Execute(str)
n = 0
For Each Match In s
If n = 0 Then
n = n + 1
ReDim ArrayFilter(n)
ArrayFilter(n) = Match
Else
bRepeat = False
For i = 0 To UBound(ArrayFilter)
If UCase(Match) = UCase(ArrayFilter(i)) Then
bRepeat = True
Exit For
End If
Next
If bRepeat = False Then
n = n + 1
ReDim Preserve ArrayFilter(n)
ArrayFilter(n) = Match
End If
End If
Next

Set s = Nothing
Set re = Nothing

If CBool(Condition) Then
strContent = Join(ArrayFilter, "|||")
Else
strContent = Join(ArrayFilter, "|||")
strContent = Replace(strContent, start, "")
strContent = Replace(strContent, last, "")
End If

CutMatchContent = Replace(strContent, "|||", vbNullString, 1, 1)
End Function

Function CutFixContent(ByVal str, ByVal start, ByVal last, ByVal n)
Dim strTemp
On Error Resume Next
If InStr(str, start) > 0 Then
Select Case n
Case 0 ''左右都截取(都取前面)(去处关键字)
strTemp = Right(str, Len(str) - InStr(str, start) - Len(start) + 1)
strTemp = Left(strTemp, InStr(strTemp, last) - 1)
Case Else ''左右都截取(都取前面)(保留关键字)
strTemp = Right(str, Len(str) - InStr(str, start) + 1)
strTemp = Left(strTemp, InStr(strTemp, last) + Len(last) - 1)
End Select
Else
strTemp = ""
End If
CutFixContent = strTemp
End Function
Private Function CorrectPattern(ByVal str)
str = Replace(str, "\", "\\")
str = Replace(str, "~", "\~")
str = Replace(str, "!", "\!")
str = Replace(str, "@", "\@")
str = Replace(str, "#", "\#")
str = Replace(str, "%", "\%")
str = Replace(str, "^", "\^")
str = Replace(str, "&", "\&")
str = Replace(str, "*", "\*")
str = Replace(str, "(", "\(")
str = Replace(str, ")", "\)")
str = Replace(str, "-", "\-")
str = Replace(str, "+", "
  • 上一篇资讯: newasp中下载类
  • 下一篇资讯: 文章列表类别
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号