我有一段UBB的嵌套引用代码,但是是VBS的,谁帮忙改成JavaScript?100分!!

billyou 2002-12-05 08:14:23
re.Pattern="(\[QUOTE\])(.*)(\[\/QUOTE\])"
replstr="<BLOCKQUOTE><BLOCKQUOTE>引用:<hr size=1 color=#000000>$2<hr size=1 color=#000000></BLOCKQUOTE></BLOCKQUOTE>"
Set Matches=re.Execute(strContent) '执行搜索
for each Match in matches
strcontent = re.Replace(strContent, replStr)
strcontent = re.Replace(strcontent, replStr)
next
谢谢了
...全文
36 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
qiushuiwuhen 2002-12-05
  • 打赏
  • 举报
回复
你处理的是嵌套的(而且不能多于两层的),如果是重复的,如第一种
就要用最小匹配,如果是高版本可以用.*?,否则用([^\[]*)
ps.还有一种利用递归的replace+function,这里就不多说了
qiushuiwuhen 2002-12-05
  • 打赏
  • 举报
回复
<script>
function rep(str){
var reg=/(\[QUOTE\])(.*)(\[\/QUOTE\])/gi
while(str.match(reg))
str=str.replace(reg,"<BLOCKQUOTE><BLOCKQUOTE>引用:<hr size=1 color=#000000>$2<hr size=1 color=#000000></BLOCKQUOTE></BLOCKQUOTE>");
return str
}
alert(rep("a[quote]b[quote]c[/Quote]d[/Quote]e"))
</script>
qiushuiwuhen 2002-12-05
  • 打赏
  • 举报
回复
<script>
function rep(str){
return str.replace(/(\[QUOTE\])(.*?)(\[\/QUOTE\])/gi,"<BLOCKQUOTE><BLOCKQUOTE>引用:<hr size=1 color=#000000>$2<hr size=1 color=#000000></BLOCKQUOTE></BLOCKQUOTE>");
}
alert(rep("a
引用
b
c[Quote]d[/Quote]e"))
</script>

87,994

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧