您现在的位置是:网站首页> 编程资料编程资料

ubb js_正则表达式_

2023-05-25 401人已围观

简介 ubb js_正则表达式_

strIcons = "1"  //允许笑脸转换
strSmile="1"   //同上
ImgName="em"
picurl="/images/emot/"

function UBBCode(content,html){
    content=content.replace("\\r","");
    content=content.replace("\\n","");
    return (trans(content));
}


function trans(strContent){
    var re;

 re=/\[IMG\](.+?)\[\/IMG\]/ig;
 strContent=strContent.replace(re,"

");
 re=/\[DIR=*([0-9]*),*([0-9]*)\](.*?)\[\/DIR]/ig
 strContent=strContent.replace(re,"")
 re=/\[QT=*([0-9]*),*([0-9]*)\](.*?)\[\/QT]/ig
 strContent=strContent.replace(re,"")
 re=/\[MP=*([0-9]*),*([0-9]*)\](.*?)\[\/MP]/ig
 strContent=strContent.replace(re,"")
 re=/\[RM=*([0-9]*),*([0-9]*)\](.*?)\[\/RM]/ig
 strContent=strContent.replace(re,"
")


 re=/(\[FLASH\])(.*?)(\[\/FLASH\])/ig
 strContent= strContent.replace(re,"$2")
 re=/(\[FLASH=*([0-9]*),*([0-9]*)\])(.*?)(\[\/FLASH\])/ig
 strContent= strContent.replace(re,"点击开新窗口欣赏该FLASH动画! [全屏欣赏]

$4")

 re=/(\[UPLOAD=gif\])(.*?)(\[\/UPLOAD\])/ig
 strContent= strContent.replace(re,"
此主题相关图片如下:
按此在新窗口浏览图片screen.width-333)this.width=screen.width-333\">")
 re=/(\[UPLOAD=jpg\])(.*?)(\[\/UPLOAD\])/ig
 strContent= strContent.replace(re,"
此主题相关图片如下:
按此在新窗口浏览图片screen.width-333)this.width=screen.width-333\">")
 re=/(\[UPLOAD=png\])(.*?)(\[\/UPLOAD\])/ig
 strContent= strContent.replace(re,"
此主题相关图片如下:
按此在新窗口浏览图片screen.width-333)this.width=screen.width-333\">")

 re=/(\[UPLOAD=swf\])(.*?)(\[\/UPLOAD\])/ig
 strContent= strContent.replace(re,"
点击开新窗口欣赏该FLASH动画! [全屏欣赏]

$2")

 re=/(\[UPLOAD=asf\])(.*?)(\[\/UPLOAD\])/ig
 strContent= strContent.replace(re,"
")
 re=/(\[UPLOAD=avi\])(.*?)(\[\/UPLOAD\])/ig
 strContent= strContent.replace(re,"
")
 re=/(\[UPLOAD=mpg\])(.*?)(\[\/UPLOAD\])/ig
 strContent= strContent.replace(re,"
")
 re=/(\[UPLOAD=wmv\])(.*?)(\[\/UPLOAD\])/ig
 strContent= strContent.replace(re,"
")

 re=/(\[UPLOAD=mp3\])(.*?)(\[\/UPLOAD\])/ig
 strContent= strContent.replace(re,"
")
 re=/(\[UPLOAD=wav\])(.*?)(\[\/UPLOAD\])/ig
 strContent= strContent.replace(re,"
")
 re=/(\[UPLOAD=mid\])(.*?)(\[\/UPLOAD\])/ig
 strContent= strContent.replace(re,"
")

    re=/(\[UPLOAD=(.[^\[]*)\])(.*?)(\[\/UPLOAD\])/ig
    strContent= strContent.replace(re,"
点击浏览该文件")

    re=/(\[refer=(\d{1,}),(.*?)\])(.*?)(\[\/refer\])/ig
    strContent=strContent.replace(re,"

回复$2楼$3发表:
$4
");

 re=/(\[URL\])(.*?)(\[\/URL\])/ig
 strContent= strContent.replace(re,"$2")
 re=/(\[URL=(.[^\[]*)\])(.*?)(\[\/URL\])/ig
 strContent= strContent.replace(re,"$3")

 re=/(\[EMAIL\])(.*?)(\[\/EMAIL\])/ig
 strContent= strContent.replace(re,"$2")
 re=/(\[EMAIL=(.[^\[]*)\])(.*?)(\[\/EMAIL\])/ig
 strContent= strContent.replace(re,"$3")

 re =/^(http:\/\/[A-Za-z0-9\.\/=\?%\-&_~`@':+!]+)/ig
 strContent = str

-六神源码网