当前位置:首页 > ASP教程 > 应用技巧

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://www.jb51.net/article/20816.htm



【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!