Javascript教程_解决JS如何过滤掉标签源码教程
var a=yinyong
我的yinyong内容是:[url=123]链接[url]
得怎样过滤里面的[url]XXX[url]标签?最好能过滤掉所有。。因为不只是[url],还有[img]...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>new document</title>
<meta name="author" content="XeonWell" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<style type="text/css">
</style>
<script type="text/javascript">
var a = "[url=123]链接[/url]kjk[url=123]链接[/url]jk[img]asdf[/img]";
var re = /\[(.+?)(?:=[^\]]+)?\](.+?)\[\/\1\]/gi;
alert(a.replace(re,"$2"));
</script>
</head>
<body>
</body>
</html>