\#是个大杀器,合理的使用可以达到特别的效果.不合理的使用就会有很多问题.
伟大理论导师菲菲说,\#看作是先入先出堆栈,这一句,我琢磨了两年才咂摸出味道.当时没有真正理解.
最近遇到不少\#的问题,看似乎没人说,就说说,如有错漏还请指正.
高手可以直接绕过这些基础看下面问题部分.
以下格式
Code: Select all
match:第一行
>:test都是123aa456bbc
\@=:replace为\@的结果
Code: Select all
初级阶段:
123\#456\#c
>123aa456bbc
\@=aabb
Code: Select all
前加[\#前加kk jj]
123$SET(#=kk)\#456$SET(#=jj)\#c
>123aa456bbc
\@=kkaajjbb
Code: Select all
后加[\#后加kk jj]
123\#456$SET(#=kk)\#c$SET(#=jj)
>123aa456bbc
\@=aakkbbjj
Code: Select all
前后加[\#前加kk 后加jj]
123$SET(#=kk)\#456\#c$SET(#=jj)
>123aa456bbc
\@=kkaabbjj
Code: Select all
替换[123aa变kk 456变jj bb不变]
123aa$SET(#=kk)456$SET(#=jj)\#c
>123aa456bbc
\@=kkjjbb
Code: Select all
替换继续抓[123aa变kk 456变jj \1删bb 继续抓c]
123aa$SET(#=kk)456$SET(#=jj)\1(c)\#
>123aa456bbc
\@=kkjjc
Code: Select all
变量参与[没什么变化 把\1(在此是bb)删除变附加]
123aa$SET(#=kk)\#456$SET(#=jj)$SET(#=\1)\1(c)\#
>123aa456bbc
\@=kkjjbbc
说说\#的使用问题
\#作前导时需要加(),除非你能确信你只用了一条\#前导且没在其他filter使用\#
(\#)aabbcc(\#ddd|eee)这种时第二个\#必须加括号变成(\#)aabbcc((\#)ddd|eee)
不然会在奇怪的地方出现奇怪的问题,而且很随机.
举例:
....找半天 我已经修正了..重改出.
同时存在两条
Code: Select all
[Patterns]
Name = "Add shadow [11.07.28]"
Active = FALSE
Multi = TRUE
Limit = 256
Match = "<div id=($AV((bookreader|content)))\# >$SET(F=font-size:16px !important;font-family:yahei-mono !important;)"
"|"
"<div id=($AV(bookreader|content))\#+\#>"
Replace = "<div id=\@ style="text-shadow: 2px 2px 2px #CCC;$GET(F)">"
Code: Select all
[Patterns]
Name = "Share : Null"
Active = TRUE
Bounds = "$NEST(<script\s,</script>)"
Limit = 512
Match = "\#(share.baidu.com|bdshare_js|bdshell_js)(\#)"
http://www.tieku.org/196575/1.html
加()为
Code: Select all
[Patterns]
Name = "Share : Null"
Active = TRUE
Bounds = "$NEST(<script\s,</script>)"
Limit = 512
Match = "(\#)(share.baidu.com|bdshare_js|bdshell_js)(\#)"
如果用
Code: Select all
[Patterns]
Name = "Add shadow [11.09.10] XXX ..."
Active = TRUE
Bounds = "$NEST(<div,>)"
Limit = 256
Match = "(<div (class|id)=($AV(bookreader|content|readAreaBox)))\#(\#((style=)\#$AV($SET(#=")\#)$SET(#=font-size:16px !important;font-family:yahei-mono !important;text-shadow: 2px 2px 2px #CCC;")\#)|(^style\=)$SET(#= style="font-size:16px !important;font-family:yahei-mono !important;text-shadow: 2px 2px 2px #CCC;")\#)"
Replace = "\@"
Code: Select all
[Patterns]
Name = "Share : Null"
Active = TRUE
Bounds = "$NEST(<script\s,</script>)"
Limit = 512
Match = "\#(share.baidu.com|bdshare_js|bdshell_js)(\#)"
但是Add shadow [11.09.10] XXX ...仍然是有问题的
和一条偷懒用的修改
Code: Select all
[Patterns]
Name = "Fix : Script src=[^/]+./"
Active = TRUE
Multi = TRUE
Bounds = "$NEST(<script\s,</script>)"
Limit = 256
Match = "(\#)(src\=)\#$AV((^http://|/|.|\\|\s)($SET(#=./)\#))(\#)"
Replace = "\@"
http://book.xhsd.net/new/html/0/5790/7.htm
出现冲突 有兴趣的可以检验以上错误 都可重现.
最终改进
Code: Select all
[Patterns]
Name = "Add shadow [11.09.20]"
Active = TRUE
Bounds = "$NEST(<div,>)"
Limit = 256
Match = "(<div (class|id)=($AV(bookreader|content|readAreaBox)))\#((\#)((style=)\#$AV($SET(#=")\#)$SET(#=font-size:16px !important;font-family:yahei-mono !important;text-shadow: 2px 2px 2px #CCC;")\#)|(^style\=)$SET(#= style="font-size:16px !important;font-family:yahei-mono !important;text-shadow: 2px 2px 2px #CCC;")\#)"
Replace = "\@"
...(\#|...)的\#加了()后...((\#)|...)再无任何冲突
因为错误的不可预知和奇怪,所以
\#作前导时要加(), ;
...(\#|...)的\#也要加括号 ;