正则表达式提取标签内的内容(数据)

w104399431 2009-12-15 02:25:07
字符串 或者页面模板内 包含{$xxx()},{$xxx(1,2,3,4,5)}的 时候,使用正则表达式将 {$}内的 数据提取出来【ASP Vbscript内使用】!

要的结果是:xxx(),xxx(1,2,3,4,5)

麻烦高手给 写出来 ,最好能解释一下 谢谢了
...全文
597 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
yan11cn 2009-12-15
  • 打赏
  • 举报
回复
以下代码测试过,应该没问题

<%
dim str,reg,str2
set reg = New RegExp
reg.Global=true
reg.Pattern="\{\$.*?\}"
'reg.Pattern="^*\n*$"
reg.IgnoreCase = false
str=" ok{$xxx()},ha哈{$xxx(1,2,3,4,5)}nihao {$hah()}"
str=trim(str)
if reg.Execute(str).count = 0 then
response.write "no such string!"
else
str2=""
set colMatches = reg.Execute(str)
for each match in colMatches
if str2="" then
str2=mid(match.value,3,len(match.value)-3)
else str2=str2&","&mid(match.value,3,len(match.value)-3)
end if
next
end if
response.write(str2)
%>

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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