FCKEditor编辑器在生成HTML格式的时候使用的是SPAN标签,加上STYLE属性来控制字体大小、颜色等,可惜FLASH中的渲染却不支持这个格式(有知道如何支持的请联系我噢)。
这个函数就是用来过滤并替换SPAN标签并转换为FONT标签,不过不完善,只能实现简单的替换,因为基础差,不懂得如何写正则,有完美解决方案的也敬请指导。
Function span2font(strcontent)
dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
strcontent=replace(strcontent,”font-”,”")
strcontent=replace(strcontent,”;”,” “)
strcontent=replace(strcontent,”: “,”=”)
strcontent=replace(strcontent,”:”,”=”)
re.pattern=”<span style=”"([^>]+?)”">(.+?)”
strcontent=re.replace(strcontent,”<font $1>$2″)
strcontent=replace(strcontent,”</span>”,”</font>”)
re.pattern=”(\s+\w+)\=([^>\""\s]+)”
strcontent=re.replace(strcontent,”$1=”"$2″”")
set re=Nothing
span2font = strcontent
End Function
span2font(“<span style=”"font-size: larger;color: #ff0000″”>关于</span><span style=”"font-weight: bold;”"></span><span style=”"color: #ff0000″”>虫子</span>”)
标签: FLASH, HowTo, VB, VBS, WYSIWYG, 正则表达式, 脚本