Re: Need help with regular expression
| From: | Daniel Brown | Date: | Wed, 09 Jul 2008 15:42:33 +0000 |
| Subject: | Re: Need help with regular expression | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-276507@lists.php.net to get a copy of this message | ||
On Wed, Jul 9, 2008 at 5:21 AM, Maxim Antonov <max@maxantonov.name> wrote:
> Hi, all!
>
> I try to use folowing regular expression:
> $out =
> preg_replace('#\{%%%.*?\{%bigfoto%\}.*?%%%\}#is','==REPLACEMENT==',$str);
>
[snip!]
>
> I need result as:
>
> <tr><td>NAME:</td><td><input type="text"
> name="name" value=""
> size="80"/></td></tr>
> <tr><td>Foto:</td><td><input type="file"
> name="foto" value="{%foto%}" />
> {%%%<br/><img alt="{%name%}" src="{%foto%}"/>%%%}
> </td></tr>
> ==REPLACEMENT==
[snip!]
To get it *exactly* as you've mentioned here, use this instead:
<?php
$out =
preg_replace('/<tr><td>Big.*\{%%%.*\{%bigfoto%\}.*%%%\}.*<\/tr>/Uis','==REPLACEMENT==',$str);
?>
--
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.