网站风格: 红 | 蓝
搜索:  全站?
首页 |  Java开发 |  DOTNET开发 |  PHP开发 |  ASP技术 |  Web开发 |  数据库应用 |  网络文摘 |  作品集 |  下载 |  留言
文章聚合
  J2EE  |   框架技术  |   Javascript  |   AJAX  |   J2ee Server  |   J2ME  |
  WinForm开发  |   Asp.net  |   C#语言  |   服务器  |   第三方控件  |
  PHP笔记  |   Linux  |   第三方代码  |
  ASP教程  |   ASP实用代码  |   ASP笔记  |   服务器  |
  CSS样式表  |   Photoshop设计  |   Flash  |   HTML 小技巧  |   Dreamweaver  |   XML技术  |
  SQL Server  |   Oracle  |   MySQL  |
  散文  |   幽默  |   杂文  |
  Web 项目  |   杂七杂八  |
  第三方代码  |   实用工具  |   作品下载  |   帮助文档  |
奇点网 - ASP技术 - ASP实用代码 - ASP实用的两个正则函数
ASP实用的两个正则函数
来源:http://www.7dit.com     作者:7dit     发布日期:2008-10-11 02:47:17   点击量:379
<%

function shownew(str,patrn,strRepl)
Dim regEx
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
regEx.Pattern = patrn
shownew = regEx.Replace(str, strRepl)
end function
Response.write shownew("12345sdf32","(\d+)","<b>$1</b>")
' 函数用于替换指定的字符串
%>


<%
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = True ' 设置是否区分大小写。
regEx.Global = True ' 设置全局替换。
Set Matches = regEx.Execute(strng) ' 执行搜索。
For Each Match in Matches ' 遍历 Matches 集合。
RetStr = RetStr & "Match " & I & " found at position "
RetStr = RetStr & Match.FirstIndex & ". Match Value is "'
RetStr = RetStr & Match.Value & "'." & vbCRLF
Next
RegExpTest = RetStr
End Function
Response.write RegExpTest("(\d{10,20}.(jpg|gif))","244234452345234534125.jpgdsfi>?oi93205920123123534643626.gif")
' 函数用于匹配指定的字符串
%>
标签:   asp  |  代码  |  正则式  |
留言 | 链接 | 标签 | 风格: 红 蓝   
Copyright © 2005 奇点中文网--7dit.com
闽ICP备05001292号