Regex help please
| From: | Shawn McKenzie | Date: | Fri, 27 Mar 2009 14:40:28 +0000 |
| Subject: | Regex help please | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-290756@lists.php.net to get a copy of this message | ||
I'm normally OK with regex, especially if I fiddle with it long enough,
however I have fiddled with this one so long that I'm either totally
missing it or it's something simple. Does it have anything to do with
the backref, or the fact that the value of the backref has a $? I have:
$out = '
{$sites}
<tr>
<td>
{Site.id}
</td>
</tr>
{/$sites}';
And I want to capture the first {$tag}, everything in between and the
last {$/tag}. I have tried several things and here is my current regex
that looks like it should work, but doesn't:
preg_match_all('|{\$([^}]+)}(.+)({/\1})|Us', $out, $matches);
Gives:
Array
(
[0] => Array
(
)
[1] => Array
(
)
[2] => Array
(
)
[3] => Array
(
)
)
--
Thanks!
-Shawn
http://www.spidean.com