如何获取字符串中特定界限的内容

ice_sea 2002-01-23 06:31:17
例如一个串 straaa = sssssss[a]www.111.com.cn[/a]bbbbbbbbb

用什么函数可以取出串中 [a]www.111.com.cn[/a] 这一段字符??
...全文
63 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
tncboy 2002-01-24
  • 打赏
  • 举报
回复
使用正则匹配方法比较方便!
asp就内置支持一个"正则表达式"对象, 看下面的例子
<%
Set regEx = New RegExp ' 建立正则表达式对象。
regEx.Pattern = "\[tncboy].+\[/tncboy]" ' 设置匹配模式。
regEx.IgnoreCase = true ' 设置是否区分字符大小写。
set Matches = regEx.Execute("hello! [tncboy]my name is [/tncboy], do you kown me") ' 匹配字符串
for each matchstr in Matches
response.write matchstr.value&"<br>" '输出结果
next
%>
而你只要修改匹配模式串:
"\[a].+\[/a]" 即可做到
如果改为
"\[.+].+\[.+]"
可匹配到所有的[..][/..]组合,当然如果一个
字符串含多个组合,将会取最外层嵌套  
希偌 2002-01-23
  • 打赏
  • 举报
回复
str1=intstr(straaa,"[a]")
str2=intstr(straaa,"[/a]")
straaa=substr(straaa,str1,str2+4)
ssm1226 2002-01-23
  • 打赏
  • 举报
回复
str="sssssss[a]www.111.com.cn[/a]bbbbbbbbb"
arr=split(str,"a]")
str="[a]"&arr(1)&"a]"

28,406

社区成员

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

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