Re: reg-exp for removing multiline html comments
| From: | Monte Ohrt | Date: | Tue, 27 Nov 2001 19:57:38 +0000 |
| Subject: | Re: reg-exp for removing multiline html comments | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2062@lists.php.net to get a copy of this message | ||
Wolfram Kriesing wrote:
>
> i guess this had been asked before but i didnt find the answer yet
>
> in the manual it says under teh section "prefilter"
>
> ----------------------
> // put this in your application, or in Smarty.addons.php
> function remove_dw_comments($tpl_source) {
> return preg_replace("/<!--#.*-->/U","",$tpl_source);
> }
> ----------------------
> can someone tell me what is the regexp for multiple line
> html-comments to be removed
Correct me if I'm wrong, but I think this will work:
preg_replace("/<!--.*-->/Us","",$tpl_source)
"s" means that the period "." wildcard includes linebreaks.
"U" means ungreedy matching so it will match individual comment blocks.
>
> to be able to remove
> this
> <!-- comment
> -->
>
> and that
> <!--
> | comment
> +-->
>
> ???
>
> i tried a lot of stuff but .... mmmm didnt find it ...
>
> i guess its to easy, right?
>
> thanks in advance
>
> --
> Wolfram
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/