Page 1 of 1

问一个关于$SET 的问题

Posted: Jun 18 2009, 09:46
by ddbb
比如我这有这个规则....
[Patterns]
Name = "Images: Litebox add code 09.06.09 [ddandyy]"
Active = TRUE
URL = "$TYPE(htm)"
Bounds = "<a\s*>"
Limit = 300
Match = "(*href="*.(jpge|gif|png|jpg)"[^>]+)\1>$SET(LBOXFLG=true)"
Replace = "<a \1 rel="lightbox[roadtrip]">"
就是当有符合条件的时候设置一个变量....

然后在另一个规则的URL部分判断......
[Patterns]
Name = "Images: Litebox JS and CSS 09.06.09 [ddandyy]"
Active = TRUE
Multi = TRUE
URL = "$TYPE(htm)$TST(LBOXFLG=true)"
Limit = 10
Match = "</body>$SET(LBOXFLG=)"
Replace = "\r\n"
"<link rel="stylesheet" href="http://local.ptron/lightbox/css/lightbox.css" type="text/css" media="screen" />\r\n"
"<script type="text/javascript" src="http://local.ptron/lightbox/js/prototyp ... cript>\r\n"
"<script type="text/javascript" src="http://local.ptron/lightbox/js/scriptac ... cript>\r\n"
"<script type="text/javascript" src="http://local.ptron/lightbox/js/lightbox ... cript>\r\n"
"</body>$STOP()"
现在的问题就是 第1个规则......

我把那个$SET写到 Match = "(*href="*.(jpge|gif|png|jpg)"[^>]+)\1>$SET(LBOXFLG=true)" 这里 就不行....第2个规则不会起作用.......
只要是Match里任何位置都不行............ 比如我试了
Match = "$SET(LBOXFLG=true)(*href="*.(jpge|gif|png|jpg)"[^>]+)\1>"
Match = "(*href="*.(jpge|gif|png|jpg)"[^>]+)\1$SET(LBOXFLG=true)>"

但是如果把这个$SET写到URL里的话 第2个规则就会起作用了........
[Patterns]
Name = "Images: Litebox add code 09.06.09 [ddandyy]"
Active = TRUE
URL = "$TYPE(htm)$SET(LBOXFLG=true)"
Bounds = "<a\s*>"
Limit = 300
Match = "(*href="*.(jpge|gif|png|jpg)"[^>]+)\1>"
Replace = "<a \1 rel="lightbox[roadtrip]">"

Re: 问一个关于$SET 的问题

Posted: Jun 18 2009, 10:31
by phoenix
引用一下 sidki 以前对类似问题的回答:
All URL fields are evaluated before all Matching Expressions, so you can't $SET something in a ME and $TST it in a UF.

Re: 问一个关于$SET 的问题

Posted: Jun 18 2009, 10:41
by ddbb
:oops:

原来是这样........明白了.......我再想别的方法.........

Re: 问一个关于$SET 的问题

Posted: Jun 18 2009, 15:02
by phoenix
你上面的例子,第二个规则就在 Match 部分 $TST 好了。