You could exclude the '}' sign from the expression

$content = ereg_replace("\{[^}]*}","",$content);

This should do the trick... i'm not 100% certain about the '[^}]'
expression, but you should find it in any regexp tutorial


Ewout de Boer

----- Original Message -----
From: "Brent Baisley" <[EMAIL PROTECTED]>
To: "php-gen" <[EMAIL PROTECTED]>
Sent: Thursday, November 14, 2002 7:32 PM
Subject: [PHP] Regular Expression trouble

> I'm trying create form template as I have seen recommended in many
> places. It seems fairly simple but I can't seem to get ereg_replace to
> work the way I want it.
> I'm starting off easy and I want to use the sample template for entering
> a new record or editing an existing one. If they are editing, then I
> obviously want to populate the form fields with values. If it's a new
> entry, I don't want any values. Simple enough.
> A form entry looks like this:
> <input type="text" ... value="{Name}">
> <input type="text" ... value="{Title}">
> So I load the template into a variable using ob_start(), etc. I assumed
> that to "clear" out all the value declarations I would simply do this:
> $content = ereg_replace("\{.*}","",$content);
> But it seems to be replacing everything between the first instance of
> { and the last instance of }, rather than each instance of {}. I've used
> regular expressions before and I even tested it using grep in BBEdit 6.5
> and it works as I would expect. I'm using PHP 4.1.2 on Mac OSX 10.1.5.
> --
> Brent Baisley
> Systems Architect
> Landover Associates, Inc.
> Search & Advisory Services for Advanced Technology Environments
> p: 212.759.6400/800.759.0577
> --
> PHP General Mailing List (
> To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to