CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

大家帮忙解释一下这段代码的作用!(大概说一下了谢谢!)

楼主sys9933(草人)2004-12-03 10:55:05 在 Web 开发 / ASP 提问

function   userubbqm(strContent)  
  if   not   isnull(strContent)   then  
  dim   re  
  dim   po,ii  
  dim   reContent  
  Set   re=new   RegExp  
  re.IgnoreCase   =true  
  re.Global=True  
   
  re.Pattern="(\[URL\])(.[^\[]*)(\[\/URL\])"  
  strContent=   re.Replace(strContent,"<A   HREF=""$2""   TARGET=_blank>$2</A>")  
  re.Pattern="(\[URL=(.[^\[]*)\])(.[^\[]*)(\[\/URL\])"  
  strContent=   re.Replace(strContent,"<A   HREF=""$2""   TARGET=_blank>$3</A>")  
   
  re.Pattern="(\[EMAIL\])(\S+\@.[^\[]*)(\[\/EMAIL\])"  
  strContent=   re.Replace(strContent,"<img   align=absmiddle   src=pic/email1.gif><A   HREF=""mailto:$2"">$2</A>")  
  re.Pattern="(\[EMAIL=(\S+\@.[^\[]*)\])(.[^\[]*)(\[\/EMAIL\])"  
  strContent=   re.Replace(strContent,"<img   align=absmiddle   src=pic/email1.gif><A   HREF=""mailto:$2""   TARGET=_blank>$3</A>")  
   
  re.Pattern="(\[FLASH\])(.[^\[]*)(\[\/FLASH\])"  
  strContent=   re.Replace(strContent,"<a   href=""$2""   TARGET=_blank><IMG   SRC=pic/swf.gif   border=0   alt=点击开新窗口欣赏该FLASH动画!   height=16   width=16>[全屏欣赏]</a><br><OBJECT   codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0   classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000   width=500   height=400><PARAM   NAME=movie   VALUE=""$2""><PARAM   NAME=quality   VALUE=high><embed   src=""$2""   quality=high   pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'   type='application/x-shockwave-flash'   width=500   height=400>$2</embed></OBJECT>")  
   
  re.Pattern="(\[FLASH=*([0-9]*),*([0-9]*)\])(.[^\[]*)(\[\/FLASH\])"  
  strContent=   re.Replace(strContent,"<a   href=""$4""   TARGET=_blank><IMG   SRC=pic/swf.gif   border=0   alt=点击开新窗口欣赏该FLASH动画!   height=16   width=16>[全屏欣赏]</a><br><OBJECT   codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0   classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000   width=$2   height=$3><PARAM   NAME=movie   VALUE=""$4""><PARAM   NAME=quality   VALUE=high><embed   src=""$4""   quality=high   pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'   type='application/x-shockwave-flash'   width=$2   height=$3>$4</embed></OBJECT>")  
   
  re.Pattern="\[color=(.[^\[]*)\](.[^\[]*)\[\/color\]"  
  strContent=re.Replace(strContent,"<font   color=$1>$2</font>")  
  re.Pattern="\[face=(.[^\[]*)\](.[^\[]*)\[\/face\]"  
  strContent=re.Replace(strContent,"<font   face=$1>$2</font>")  
  re.Pattern="\[align=(center|left|right)\](.*)\[\/align\]"  
  strContent=re.Replace(strContent,"<div   align=$1>$2</div>")  
   
  re.Pattern="\[fly\](.*)\[\/fly\]"  
  strContent=re.Replace(strContent,"<marquee   width=90%   behavior=alternate   scrollamount=3>$1</marquee>")  
  re.Pattern="\[move\](.*)\[\/move\]"  
  strContent=re.Replace(strContent,"<MARQUEE   scrollamount=3>$1</marquee>")  
  re.Pattern="\[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/GLOW]"  
  strContent=re.Replace(strContent,"<table   width=$1   style=""filter:glow(color=$2,   strength=$3)"">$4</table>")  
  re.Pattern="\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/SHADOW]"  
  strContent=re.Replace(strContent,"<table   width=$1   style=""filter:shadow(color=$2,   strength=$3)"">$4</table>")  
  re.Pattern="(\[sound\])(.[^\[]*)(\[\/sound\])"    
  strContent=re.Replace(strContent,"<a   href=""$2""   target=_blank><IMG   SRC=pic/mid.gif   border=0   alt='背景音乐'></a><bgsound   src=""$2""   loop=""-1"">")  
   
  re.Pattern="\[i\](.[^\[]*)\[\/i\]"  
  strContent=re.Replace(strContent,"<i>$1</i>")  
  re.Pattern="\[u\](.[^\[]*)(\[\/u\])"  
  strContent=re.Replace(strContent,"<u>$1</u>")  
  re.Pattern="\[b\](.[^\[]*)(\[\/b\])"  
  strContent=re.Replace(strContent,"<b>$1</b>")  
  re.Pattern="\[size=([1-4])\](.[^\[]*)\[\/size\]"  
  strContent=re.Replace(strContent,"<font   size=$1>$2</font>")  
  re.Pattern="(\[em(.[^\[]*)\])"  
  strContent=re.Replace(strContent,"<img   src=pic/em$2.gif   border=0   align=middle>")  
   
  re.Pattern="(\[IMG\])(.[^\[]*)(\[\/IMG\])"  
  strContent=re.Replace(strContent,"<a   href=""$2""   target=_blank><IMG   SRC=""$2""   border=0   onLoad=""javascript:if(this.width>580)this.width=580""   alt=按此在新窗口浏览图片></a><br>")  
   
  strContent=ChkBadWords(strContent)  
  userubbqm=replace(strContent,vbCrlf,"<br>")  
  end   if  
  end   function  
  问题点数:0、回复次数:3Top

1 楼zhouyouok(迷路的羔羊)回复于 2004-12-03 11:10:02 得分 0

是正则啊,晕死了,不懂,帮你顶。Top

2 楼yidao2004(一刀)回复于 2004-12-03 11:22:04 得分 0

这个是ubb的基本功能的实现啊。就是把用户在编辑时候产生的ubb代码替换成相应的html标签  
   
  这样,在html中访问的时候,就会出现预期的效果,否则,这些效果只能以代码的形式出现Top

3 楼wxq4100798(aa)回复于 2004-12-03 11:31:42 得分 0

嘿嘿,反正说白啦,就是字符替换,要真想看明白,就得好好研究一下正则,不了解正则,就是说了,你也不懂Top

相关问题

  • 高手帮忙解释一下C# 代码的作用!~
  • 解释代码
  • 请解释以下代码的作用(一个新手的简单问题)
  • 谁能解释一下这段代码中VOID的作用吗?谢谢啦!
  • 代码的作用??????????
  • 求高手帮忙解释一下这个页面代码每一句具体的作用,急~~~
  • 求高手帮忙解释一下这个页面代码每一句具体的作用,急~~~
  • 请解释下面代码?
  • 解释一点点代码:
  • 帮忙解释下代码?

关键词

  • 代码
  • strcontent
  • re
  • pattern
  • replace

得分解答快速导航

  • 帖主:sys9933

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo