正则表达式的问题

yaobx1983 2010-07-31 03:45:20
字符串head,bottom
如何匹配head作为开头,bottom作为结尾的字符串?
head************bottom,正则表达式怎样写?
...全文
96 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
竹贤侄 2010-07-31
  • 打赏
  • 举报
回复
<%
function findhb(str)
set re=new Regexp
re.Global = True
re.IgnoreCase = True
re.pattern="^head[\s\S]*bottom$"
Set Matches = re.Execute(str)
For Each Match in Matches
RetStr = RetStr & "找到第 "
RetStr = RetStr & Match.FirstIndex+1 & "个匹配项的值是:'"
RetStr = RetStr & Match.Value & "'." & vbCRLF &"<br>"
Next
findhb=RetStr
end function

str="headasdfsdfsafasf asdfasdfbottom"

response.Write(findhb(str))


%>
  • 打赏
  • 举报
回复
^head[\s\S]*bottom$
sd5816690 2010-07-31
  • 打赏
  • 举报
回复
^head.*?bottom$
sd5816690 2010-07-31
  • 打赏
  • 举报
回复
^head.*?bottom$
sd5816690 2010-07-31
  • 打赏
  • 举报
回复
^head.*?bottom$

28,409

社区成员

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

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