asp中匹配<%%>的正则表达式怎么写

aiqidai 2009-07-29 03:12:37
asp中匹配<%%>的正则表达式怎么写
就是要匹配asp中的<%...%>
其中会有很多个<%...%>
...全文
138 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
mocom 2009-07-29
  • 打赏
  • 举报
回复
regEx.Pattern = "<" & "%([\s\S]*?)%" & ">"
aiqidai 2009-07-29
  • 打赏
  • 举报
回复
未结束的字符串常量
regEx.Pattern=" <%(.[^ <>]*)
----------------------------^

regEx.Pattern=" <%(.[^ <>]*)%>"
如果包括任何字符呢?
还是是不是要加成
regEx.Pattern=" \ <\%(.[^ <>]*)\%\>"

这样的?
aiqidai 2009-07-29
  • 打赏
  • 举报
回复
regEx.Pattern=" <%(.[^ <>]*)%>"
如果包括任何字符呢?
还是是不是要加成
regEx.Pattern=" \<\%(.[^ <>]*)\%\>"

这样的?
shenzhenNBA 2009-07-29
  • 打赏
  • 举报
回复
regEx.Pattern="<%(.[^ <>]*)%>"
shenzhenNBA 2009-07-29
  • 打赏
  • 举报
回复
[Quote=引用楼主 aiqidai 的回复:]
asp中匹配 <%%>的正则表达式怎么写
就是要匹配asp中的 <%...%>
其中会有很多个 <%...%>

[/Quote]

Set regEx = New RegExp
regEx.Pattern="<%(.[^<>]*)%>"
...

匹配任意但不包括 < , > 符号
aiqidai 2009-07-29
  • 打赏
  • 举报
回复
我是ASP里用的
aiqidai 2009-07-29
  • 打赏
  • 举报
回复
regEx.Pattern = "/<\%(.*)\
--------------------------^
zpzk123 2009-07-29
  • 打赏
  • 举报
回复
"/ <\%(.*)\%>/U"
zpzk123 2009-07-29
  • 打赏
  • 举报
回复
"/<\%(.*)\%>/"
aiqidai 2009-07-29
  • 打赏
  • 举报
回复
Function ReplaceCondition(byval str)
Dim regEx, Matches, Match, TempStr,Bool
Dim FieldParam,FieldParamArr,ReturnFieldValue,I
on error resume next
Set regEx = New RegExp
regEx.Pattern = "{\$IF\([^\$]*}"
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(str)
TempStr=str
For Each Match In Matches
FieldParam = Replace(Match.Value,"{$IF(","")
FieldParam =mid(FieldParam,1,(len(FieldParam)-2))
FieldParamArr = Split(FieldParam,"||")
Bool=eval(trim(FieldParamArr(0)))
If Bool="True" Then
ReturnFieldValue=FieldParamArr(1)
Else
ReturnFieldValue=FieldParamArr(2)
End If
TempStr=Replace(TempStr,"{$IF(" &FieldParam &")}",ReturnFieldValue)
Next
ReplaceCondition=TempStr
End Function
可参考 这个函数,替换文本中的{$if(条件||1||2)}这样标签的

28,409

社区成员

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

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