复制代码 代码如下:<% str = request("str") reg = request("reg") set regex = new RegExp With regex .Pattern = reg .IgnoreCase = False .Global = True End With Set match = regex.Execute(str) If match.Count > 0 Then For Each matched in match Response.Write "<B><input value=" & matched.Value & " ></B> 位置: <B>" & matched.FirstIndex & "</B> 长 度:"&matched.Length&"<BR>" Next Else Response.Write "<B>" & regex.Pattern & "</B> 没有找到匹配" End If Set regex = nothing %> <form method=post> text:<br> <textarea cols=50 rows=10 name="str"><%=str%></textarea><br> regexp:<input name="reg" value="<%=reg%>"><br> <input type=submit value="regexp"> </form>关于具体的正则表达式函数http://www.jb51.net/article/20816.htm
推荐阅读
ASP去掉字符串头尾连续回车和空格的Function
'去掉字符串头尾的连续的回车和空格 function trimVBcrlf(str) trimVBcrlf=rtrimVBcrlf(ltrimVBcrlf(str)) end function '去掉字符串开头的连续的回车和空格 function ltrimVBcrlf(str) dim pos,isBlankChar pos=1>>>详细阅读
本文标题:ASP正则表达式技巧
地址:http://www.17bianji.com/kaifa2/ASP/32129.html
1/2 1