此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【xyflash】截止到2008-06-28 18:22:59的历史汇总数据(不包括此帖):
发帖数:203 发帖分:3595
结贴数:153 结贴分:2720
未结数:50 未结分:875
结贴率:75.37 % 结分率:75.66 %
楼主加油
楼主【xyflash】截止到2008-06-28 18:22:59的历史汇总数据(不包括此帖):
发帖数:203 发帖分:3595
结贴数:153 结贴分:2720
未结数:50 未结分:875
结贴率:75.37 % 结分率:75.66 %
楼主加油
第一个转换<SCRIPT LANGUAGE="JavaScript">
<!--
var str = "";
str = str.replace(/\[img=(\d*)(,)(\d*)\]([^\[]*)\[\/img\]/ig,'<img src="$4" border="0" width="$1" height="$3" />');
alert(str)
//-->
</SCRIPT>
第二个转换
var str = "[html]http://cn.yimg.com/i/comn/lg07/ylgfanyi.gif[/html]";
str = str.replace(/\[html\]([^\[]*)\[\/html\]/ig,'<textarea name ="textarea" >$1</textarea>');
alert(str)
看还需要什么限制不???
将hrml转回ubb 这个到吗对不对?
var pcodecount = '-1';
var codecount = 0;
var codehtml = new Array();
//过滤空格
function trim(str) {
return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, '');
}
//替换url
function parseurl(str, mode) {
str = str.replace(/([^>=\]"'\/]|^)((((https?|ftp):\/\/)|www\.)([\w\-]+\.)*[\w\-\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!]*)+\.(jpg|gif|png|bmp))/ig, mode == 'html' ? '$1<img src="$2" border="0">' : '$1');
str = str.replace(/([^>=\]"'\/@]|^)((((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k):\/\/)|www\.)([\w\-]+\.)*[:\.@\-\w\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!#]*)*)/ig, mode == 'html' ? '$1<a href="$2" target="_blank">$2</a>' : '$1$2');
str = str.replace(/([^\w>=\]:"'\.\/]|^)(([\-\.\w]+@[\.\-\w]+(\.\w+)+))/ig, mode == 'html' ? '$1<a href="mailto:$2">$2</a>' : '$1$2');
return str;
}
//判断变量是否已经定义
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
//
function ubb2html(str) {
str = trim(str);
if(str == '') {
return '';
}
// str= str.replace(/\s*\[code\]([\s\S]+?)\[\/code\]\s*/ig, function($1, $2) {return parsecode($2);});
//不替换html标签
// str = str.replace(/</g, '<');
// str = str.replace(/>/g, '>');
//是否禁用url
str = parseurl(str, 'html');
//解析变量
str = str.replace(/\[url\]\s*(www.|https?:\/\/|ftp:\/\/|gopher:\/\/|news:\/\/|telnet:\/\/|rtsp:\/\/|mms:\/\/|callto:\/\/|bctp:\/\/|ed2k:\/\/){1}([^\[\"']+?)\s*\[\/url\]/ig, function($1, $2, $3) {return cuturl($2 + $3);});
str = str.replace(/\[url=www.([^\[\"']+?)\](.+?)\[\/url\]/ig, '<a href="http://www.$1" target="_blank">$2</a>');
str = str.replace(/\[url=(https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k){1}:\/\/([^\[\"']+?)\]([\s\S]+?)\[\/url\]/ig, '<a href="$1://$2" target="_blank">$3</a>');
str = str.replace(/\[email\](.*?)\[\/email\]/ig, '<a href="mailto:$1">$1</a>');
str = str.replace(/\[email=(.[^\[]*)\](.*?)\[\/email\]/ig, '<a href="mailto:$1" target="_blank">$2</a>');
str = str.replace(/\[color=([^\[\<]+?)\]/ig, '<font color="$1">');
str = str.replace(/\[size=(\d+?)\]/ig, '<font size="$1">');
str = str.replace(/\[size=(\d+(\.\d+)?(px|pt|in|cm|mm|pc|em|ex|%)+?)\]/ig, '<font style="font-size: $1">');
str = str.replace(/\[font=([^\[\<]+?)\]/ig, '<font face="$1">');
str = str.replace(/\[align=([^\[\<]+?)\]/ig, '<p align="$1">');
str = str.replace(/\[float=([^\[\<]+?)\]/ig, '<br style="clear: both"><span style="float: $1;">'); re = /\[table(?:=(\d{1,4}%?)(?:,([\(\)%,#\w ]+))?)?\]\s*([\s\S]+?)\s*\[\/table\]/ig;
for (i = 0; i < 4; i++) {
str = str.replace(re, function($1, $2, $3, $4) {return parsetable($2, $3, $4);});
} str = preg_replace([
'\\\[\\\/color\\\]', '\\\[\\\/size\\\]', '\\\[\\\/font\\\]', '\\\[\\\/align\\\]', '\\\[b\\\]', '\\\[\\\/b\\\]',
'\\\[i\\\]', '\\\[\\\/i\\\]', '\\\[u\\\]', '\\\[\\\/u\\\]', '\\\[list\\\]', '\\\[list=1\\\]', '\\\[list=a\\\]',
'\\\[list=A\\\]', '\\\[\\\*\\\]', '\\\[\\\/list\\\]', '\\\[indent\\\]', '\\\[\\\/indent\\\]', '\\\[\\\/float\\\]'
], [
'</font>', '</font>', '</font>', '</p>', '<b>', '</b>', '<i>',
'</i>', '<u>', '</u>', '<ul>', '<ul type=1>', '<ul type=a>',
'<ul type=A>', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>'
], str);
//解析img标签
str = str.replace(/\[localimg=(\d{1,4}),(\d{1,4})\](\d+)\[\/localimg\]/ig, function ($1, $2, $3, $4) {if($('attach_' + $4)) {var src = $('attach_' + $4).value; if(src != '') return '<img style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=\'scale\',src=\'' + src + '\');width:' + $2 + ';height=' + $3 + '" src=\'images/common/none.gif\' border="0" aid="attach_' + $4 + '" alt="" />';}});
str = str.replace(/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ig, '<img src="$1" border="0" onload="attachimg(this, \'load\', \'Click here to open new window\\nCTRL+Mouse wheel to zoom in/out\')" onmouseover="attachimg(this, \'mouseover\')" onclick="attachimg(this, \'click\', \'$1\')" onmousewheel="return imgzoom(this)" alt="" />');// str = str.replace(/\[attachimg\](\d+)\[\/attachimg\]/ig, '<img src="attachment.aspx?attachmentid=$1" border="0" aid="attachimg_$1" alt="" />'); str = str.replace(/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ig, '<img width="$1" height="$2" src="$3" border="0" alt="" />');
//str = str.replace("<","<").replace(">",">");
return str;
}
//
function parsetable(width, bgcolor, str) { if(isUndefined(width)) {
var width = '';
} else {
width = width.substr(width.length - 1, width.length) == '%' ? (width.substr(0, width.length - 1) <= 98 ? width : '98%') : (width <= 560 ? width : '98%');
} str = str.replace(/\[tr(?:=([\(\)%,#\w]+))?\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ig, function($1, $2, $3, $4, $5) {
return '<tr' + ($2 ? ' style="background: ' + $2 + '"' : '') + '><td' + ($3 ? ' colspan="' + $3 + '"' : '') + ($4 ? ' rowspan="' + $4 + '"' : '') + ($5 ? ' width="' + $5 + '"' : '') + '>';
});
str = str.replace(/\[\/td\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ig, function($1, $2, $3, $4) {
return '</td><td' + ($2 ? ' colspan="' + $2 + '"' : '') + ($3 ? ' rowspan="' + $3 + '"' : '') + ($4 ? ' width="' + $4 + '"' : '') + '>';
});
str = str.replace(/\[\/td\]\s*\[\/tr\]/ig, '</td></tr>'); return '<table ' + (width == '' ? '' : 'width="' + width + '" ') + 'align="center" class="t_table"' + (isUndefined(bgcolor) ? '' : ' style="background: ' + bgcolor + '"') + '>' + str + '</table>';
}
//
function preg_replace(search, replace, str) {
var len = search.length;
for(var i = 0; i < len; i++) {
re = new RegExp(search[i], "ig");
str = str.replace(re, typeof replace == 'string' ? replace : (replace[i] ? replace[i] : replace[0]));
}
return str;
}
function($1, $2, $3, $4) {
return '</td><td' + ($2 ? ' colspan="' + $2 + '"' : '') + ($3 ? ' rowspan="' + $3 + '"' : '') + ($4 ? ' width="' + $4 + '"' : '') + '>';
}直接返回不行吗 为什么非要 function($1, $2, $3, $4) { 下??