Hello!
2014-06-18 23:03 GMT-07:00 will:
>
> replace_filter作者,你好:
> 我想使用replace_filter进行多行匹配,目前对你的模块还不熟悉,不知道如何匹配换行。如下面一段代码:
> <div class="yt-alert-panel "> <div class="yt-grid-box">
>
> <div id=yt-lang-alert-content">
> <div class="yt-lang-alert-controls">
>
> 请问该如何匹配上面这段代码并替换。
可以考虑使用下面这一行配置:
replace_filter '<div class="yt-alert-panel ">\s*<div
class="yt-grid-box">\s*<div id=yt-lang-alert-content">\s*<div
class="yt-lang-alert-controls">' 'Something new' g;
不过要小心 MIME 设置,见
https://github.com/openresty/replace-filter-nginx-module#replace_filter_types
默认只有 Content-Type 响应头里有 text/html 的响应才会被处理。
> 另外,replace_filter支持javascript的匹配吗?
>
你是指 Javascript 语义的正则表达式变种,还是指对内容是 JavaScript 源码的响应体文本进行替换?
如果是前者,ngx_replace_filter 所依赖的 sregex 正则引擎并不支持 JavaScript 正则语义(见
https://github.com/openresty/sregex#readme );如果是后者,则自然没有问题(但要小心 MIME
类型,见上面的说明)。
另外,建议加入 openresty 中文邮件列表讨论这样的问题,谢谢合作!见 https://groups.google.com/group/openresty
同时抄送给该列表。
Regards,
-agentzh