日期:2014-05-17  浏览次数:21153 次

正则表达式怎样替换掉全部
<%
str= " <> 123 <> "
Set   r   =   New   RegExp

r.Pattern   =   " <.*?> "
str2   =   r.replace(str, " ")

Response.write   str2
%>

这个只替换掉   一个 <>
有多个的话,怎么写?

------解决方案--------------------
加上 re.MultiLine = True
试试

------解决方案--------------------
<textarea id=textarea1>
<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " lang= "gb2312 ">
<head>
<title> ASP中正则表达式的应用 - 第2页 - IT168 </title>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " >
<meta name= "description " content= "  二、正则表达式在VBScript中的应用   VBScript使用RegExp对象、Matches集合以及Match对象提供正则表达式支持功能。我们还是先看一个例子。   ;%   Func...... " >
<meta name= "keywords " content= "ASP中正则表达式的应用|服务器专区|IT168 " />
<link rel= "StyleSheet " href= "/2006include/style.css " type= "text/css " media= "screen " />
<script type= "text/javascript ">
var chanstr= "14 ";
</script>
</head>
<body> <center>

</textarea>

<script>
alert(aaa(textarea1.value))
function aaa(x)
{
var rtn= " ";
var arr = x.match(/ <[^> ]*> (.*?) <[^> ]*> /ig);
for(i=0;i <arr.length;i++)
{
rtn += arr[i].replace(/ <[^> ]*> /ig, " ") + "\n ";
}
return(rtn);
}
</script>
试试吧