Closed bhargavtrivedi closed 10 years ago
Hello!
On Mon, Oct 28, 2013 at 6:59 AM, bhargavtrivedi notifications@github.com wrote:
I have also used below code to remove space and blank lines but it works for existing blank lines only. It doesn't remove the balnk lines create by removing some strings etc. replace_filter '^\s+|\s+$' '' g;
Is there any code which can just remove the blank lines (without space)?
I don't quite understand your question. Could you elaborate by giving some sample C++ code (and the expected filtering output)?
One more question, if we use multiple replace_filter code, in which sequence will it be executed?
Logically speaking, all the regexes in the replace_filter directives are executed at the same time (and in a single run), but with different priorities according to their order in nginx.conf.
Best regards, -agentzh
Hi,
I tried to remove comments from backend response in Nginx using below code(I found this in README)
replace_filter "'(?:\\\\[^\n]|[^'\n])*'" $& g;
replace_filter '"(?:\\\\[^\n]|[^"\n])*"' $& g;
replace_filter '/\*.*?\*/|//[^\n]*' '' g;
The above code removes the comment but leaves the blank line in response.
I have also used below code to remove blank lines from backend response. replace_filter '^\s+|\s+$' '' g;
It removes the leading and trailing spaces as well as blank lines from backend response but it doesn't remove the blank lines which are created with removing the comments(using above regex).
Regards, Bhargav
@bhargavtrivedi You should not assume the substitutions are performed in multiple separate passes, rather, you should design your patterns for one single pass.
So you should remove adjacent spaces along with the comments, that is,
replace_filter '\s*(?:/\*.*?\*/|//[^\n]*)\s*' '' g;
Regards, -agentzh
Hi,
Thanks for your quick response. I will check your given code.
Best regards, Bhargav
Hi,
I tried removing comments using below code which results in blank line. replacefilter "'(?:\[^\n]|[^'\n])'" $& g; replacefilter '"(?:\[^\n]|[^"\n])"' $& g; replacefilter '/*.?_/|//[^\n]*' '' g;
I have also used below code to remove space and blank lines but it works for existing blank lines only. It doesn't remove the balnk lines create by removing some strings etc. replace_filter '^\s+|\s+$' '' g;
Is there any code which can just remove the blank lines (without space)?
One more question, if we use multiple replace_filter code, in which sequence will it be executed?
Thanks, Bhargav