以下是引用foktime在2010-9-9 08:33:20的发言:
怎么会没效果呢 正则已经没有问题了啊 给你下面代码你测试一下。
alert(ieHTML(''));
alert(ieHTML('。。编程论坛'));
function ieHTML(content)
{
var okText = content.replace(/<(\/?)(\w+)([^>]*)>/g,function(match,$1,$2,$3){
if($1){
return "";
}
return ("<" + $2.toLowerCase() + $3 + ">").replace(/=(("[^"]*?")|('[^']*?')|([^\s]+))([\s>])/g, function(match2, $1, $2, $3, $4, $5, position, all) {
if($4){
return '="'+ $4 +'"'+ $5;
}
return match2;
})
});
return okText.replace(/<\/?([^>]+)(?=\=)>/g, function(lele) { return lele.toLowerCase(); });
}仔细检查检查看别的地方是不是有问题
可以了.xixi...怎么会没效果呢 正则已经没有问题了啊 给你下面代码你测试一下。
alert(ieHTML(''));
alert(ieHTML('。。编程论坛'));
function ieHTML(content)
{
var okText = content.replace(/<(\/?)(\w+)([^>]*)>/g,function(match,$1,$2,$3){
if($1){
return "";
}
return ("<" + $2.toLowerCase() + $3 + ">").replace(/=(("[^"]*?")|('[^']*?')|([^\s]+))([\s>])/g, function(match2, $1, $2, $3, $4, $5, position, all) {
if($4){
return '="'+ $4 +'"'+ $5;
}
return match2;
})
});
return okText.replace(/<\/?([^>]+)(?=\=)>/g, function(lele) { return lele.toLowerCase(); });
}仔细检查检查看别的地方是不是有问题
直接复制这段代码覆盖之前的。有效果了。
对比了代码,是一样的。不同的是我写代码时格式用的是C#的风格。。
if($1)
{
......
}

谢谢。。。


学习编程www.