- ·上一篇文章:fso实现将整个文件夹复制到另一个文件夹中
- ·下一篇文章:Win2003 64位下ASP连接Access数据库的解决方法
asp利用正则过滤文章内容中的所有链接
一些在允许用户发布信息的时候,为了不让用户在其中发布链接,可使用正则将用户发布的信息中的超级链接给过滤掉。即使用户发布了,写入到数据库中的文章内容也没有了,这样让用户自觉的不再发布带有链接的文字了。具体实现的代码:
<
%
Function LoseATag(ContentStr)
 
 
 
 
Dim ClsTempLoseStr,regEx
 
 
 
ClsTempLoseStr = Cstr(ContentStr)
 
 
 
 
Set regEx = New RegExp
 
 
 
 
regEx.Pattern = "
<
(\/)
{0,1}a[^<
>
]*>
"
 
 
 
 
regEx.IgnoreCase = True
 
 
 
 
regEx.Global = True
 
 
 
 
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"
"
)
 
 
 
 
LoseATag = ClsTempLoseStr
 
 
 
 
Set regEx = Nothing
End Function
str="
sdfsdfsd<
a href="
"
http://www.baidu.com"
"
>
www.baidu.com<
/a>
123456789"
response.write "
输出原始的结果是:"
&
str&
"
<
br>
"
response.write "
过滤后的结果是:"
&
LoseATag(str)&
"
<
br>
"
%>
asp利用正则过滤文章内容中的所有链接