s = string.gsub("<q>aaa</q>","<q>(.*)./q>","%1")
d = string.gsub("<w>bbb</w>","<w>(.*)</w)","<w>" .. s .. "</w>")
理论上应该是没用的,只是在 lua 上写错误的,大神帮帮小弟。在此谢过~
1
hopewinn OP s = string.gsub("<q>aaa</q>","<q>(.*)./q>","%1")
d = string.gsub("<w>bbb</w>","<w>(.*)</w","<w>" .. s .. "</w>") 不好意思 多个)号,这样是对的,能显示的出, 但是用到 nginx 的时候 s = string.gsub(_body,"<title>(.*)</title>","%1") _body = string.gsub(_body,"<div class=\\"block_title\\">我(.*)势</div>","<div class=\\"block_title\\">" .. s .. "</div>") 出错!! 然后,使用自己定义的,是对的!我晕了哦 s = "aaaa" _body = string.gsub(_body,"<div class=\\"block_title\\">我(.*)势</div>","<div class=\\"block_title\\">" .. s .. "</div>") |
2
hopewinn OP 问题已解决。
|
3
knightdf 2016-10-26 20:24:43 +08:00
> b = "<w>bbb</w>"
> string.gsub("<q>aaa</q>", "<q>(.-)</q>", function(s) print(b:gsub("(<w>)(.-)(</w>)", "%1"..s.."%3")) end) |