You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Nick Gearls <ni...@gmail.com> on 2009/03/19 15:43:27 UTC
mod_substitute & \n
I found a problem with handling of new lines in mod_substitute.
Take the following file as example
<html>
<body>
</body>
</html>
1. If I use "Substitute s/\n/1/", it works almost correctly:
<html>
1<body>
1</body>
1</html>
1
Note that it does not replace the new line, but adds the replacement
after it. This is quite weird.
2. If I use "Substitute s/<body>\n/<body>2/" or
"Substitute s/\n<body>/<body>2/", the file is unchanged
Could somebody explain how newlines are handled ?
Can we use them inside a pattern ?
Thanks,
Nick
Re: mod_substitute & \n
Posted by "Plüm, Rüdiger, VF-Group" <ru...@vodafone.com>.
Using newlines in the expression does not make sense as
mod_substitute (similar to sed) does apply the regular expression
line by line. You cannot process multiline regexs with mod_substitute.
Regards
Rüdiger
> -----Ursprüngliche Nachricht-----
> Von: Nick Gearls
> Gesendet: Donnerstag, 19. März 2009 15:43
> An: dev@httpd.apache.org
> Betreff: mod_substitute & \n
>
> I found a problem with handling of new lines in mod_substitute.
> Take the following file as example
> <html>
> <body>
> </body>
> </html>
>
>
> 1. If I use "Substitute s/\n/1/", it works almost correctly:
> <html>
> 1<body>
> 1</body>
> 1</html>
> 1
> Note that it does not replace the new line, but adds the replacement
> after it. This is quite weird.
>
> 2. If I use "Substitute s/<body>\n/<body>2/" or
> "Substitute s/\n<body>/<body>2/", the file is unchanged
>
>
> Could somebody explain how newlines are handled ?
> Can we use them inside a pattern ?
>
> Thanks,
>
>
> Nick
>
>