Need help with regular expression
| From: | Maxim Antonov | Date: | Wed, 09 Jul 2008 09:21:17 +0000 |
| Subject: | Need help with regular expression | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-276488@lists.php.net to get a copy of this message | ||
Hi, all!
I try to use folowing regular expression:
$out = preg_replace('#\{%%%.*?\{%bigfoto%\}.*?%%%\}#is','==REPLACEMENT==',$str);
It not work as I need. Please tell me - what I do wrong?
I have string:
<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>
<tr><td>Big foto:</td><td><input type="file" name="bigfoto" value="" />
{%%%<br/><img alt="{%name%}" src="{%bigfoto%}"/>%%%}
</td></tr>
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==
And I have this result:
<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%}" />
==REPLACEMENT==
</td></tr>