搜索:
首页 >> Asp教程 >> Asp经验技巧 >> ASP正则表达式技巧

ASP正则表达式技巧

2011-4-10 来源:asp之家 网友评论投递文章


代码如下:

<% 

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://tool.aspxhome.com/RegExp-Tester.htm

Tags:ASP  正则表达式 
站长工具
IP地址/域名归属地查询:
相关文章
loading 请稍等,评论加载中...

学习Asp到Asp之家(Aspxhome.com)

闽ICP备06017341号