asp字符串问题

ybice 2010-05-28 10:07:24
有一个字符 <1>abc<1><3>xyz<3><10>sss<10>
我想得到如下值:
1 abc
3 xyz
10 sss
用asp怎么实现.
...全文
112 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
ybice 2010-05-28
  • 打赏
  • 举报
回复
好了,结帖了
fjfndfjf 2010-05-28
  • 打赏
  • 举报
回复
正则式太强大了!~
不过学习起来也感觉挺难的。
sxdtlcx 2010-05-28
  • 打赏
  • 举报
回复
学习学习...
zdzql 2010-05-28
  • 打赏
  • 举报
回复
学习了
shan1119 2010-05-28
  • 打赏
  • 举报
回复
<%@ Language=VBScript %>

<%
dim re
Set re=new RegExp
re.IgnoreCase =true

dim strcontent,p

'p=request.QueryString("id")
p=10
strcontent="<1>abc<1><3>xyz<3><10>sss<10>"


re.Pattern=".*?<("&p&")>(.*?)<\1>.*?"

response.write re.replace(strcontent,"$1 $2<br>")

%>
ybice 2010-05-28
  • 打赏
  • 举报
回复
再问一下,如果我要传一个参数进来, 假如是 10 ,就得到值 10 sss ,有没有简单一点的方法
shan1119 2010-05-28
  • 打赏
  • 举报
回复
    dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True

re.Pattern="<([^>]+)>(.*?)<\1>"

strcontent="<1>abc<1><3>xyz<3><10>sss<10>"
response.write re.replace(strcontent,"$1 $2<br>")
gingerkang 2010-05-28
  • 打赏
  • 举报
回复

<%
dim s,i
s="<1>abc<1><3>xyz<3><10>sss<10>"
with new regexp
.pattern="<(\d+)>(.*?)<\1>"
.ignorecase=true
.global=true
response.write "<pre>"
for each i in .execute(s)
response.write i.submatches(0) & chr(9) & i.submatches(1) & vbcrlf
next
response.write "</pre>"
end with
%>
挨踢直男 2010-05-28
  • 打赏
  • 举报
回复
str = "<1>abc<1><3>xyz<3><10>sss<10>"
str = replace(str,">","")
arr = split(str,"<")

for i= 0 to ubound(arr)
if i mod 2 = 0 then
arr(i)="</br>"
end if

x = x&arr(i)


next
response.Write x
bancxc 2010-05-28
  • 打赏
  • 举报
回复
这也不是xml

28,391

社区成员

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

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