function html_trans(str) {
str = str.replace(/\\r/g,"");
str = str.replace(/on(load|click|dbclick|mouseover|mousedown|mouseup)="[^"]+"/ig,"");
str = str.replace(/
str = str.replace(/]+href="([^"]+)"[^>]*>(.*?)<\\/a>/ig,"\\n[url=\$1]\$2[/url]\\n");
str = str.replace(/]+color=([^ >]+)[^>]*>(.*?)<\\/font>/ig,"\\n[color=\$1]\$2[/color]\\n");
str = str.replace(/]+src="([^"]+)"[^>]*>/ig,"\\n[img]\$1[/img]\\n");
str = str.replace(/<(b|strong)>(.*?)<\\/(b|strong)>/ig,"[b]\$2[/b]");
str = str.replace(/(.*?)<\\/u>/ig,"[u]\$1[/u]");
str = str.replace(/(.*?)<\\/i>/ig,"[i]\$1[/i]");
str = str.replace(/ /g," ");
str = str.replace(/&/g,"&");
str = str.replace(/"/g,"\\"");
str = str.replace(/,"<");
str = str.replace(/>/g,">");
str = str.replace(/
/ig,"\\n");
str = str.replace(/<[^>]*?>/g,"");
str = str.replace(/\\[url=([^\\]]+)\\]\\n(\\[img\\]\\1\\[\\/img\\])\\n\\[\\/url\\]/g,"\$2");
str = str.replace(/\\n+/g,"\\n");
return str;
}
用这段代替看看
加入php或者perl里的时候 类似 \n 都要变成 \\n 才可以。