ASP正则表达式技巧
程序员文章站
2024-01-22 12:22:10
复制代码 代码如下:<% str = request("str") reg = request("reg") set regex = new regexp with...
复制代码 代码如下:
<%
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>
关于具体的正则表达式函数