Re: ereg_replace and eval()
| From: | Monte Ohrt | Date: | Thu, 26 Oct 2000 15:11:47 +0000 |
| Subject: | Re: ereg_replace and eval() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-22147@lists.php.net to get a copy of this message | ||
Hi Darcy,
You can try using preg_replace(), then you can use your familiar perl
syntax.
Monte
"darcy w. christ" wrote:
>
> Hi,
>
> does anyone know a way to find and replace any words that begin with $
> and eval() them so that they are expanded? i'm reading in a file that
> may have variables in it, which i need to evaluate and i'm having
> trouble working with ereg_replace. i know how to do this in perl, but
> i'm not sure how to do this with the POSIX ereg_replace.
>
> i've started with this, but i',m not sure how to include the eval:
>
> ereg_replace("(\$[^ ])","\\1",$buffer);
>
> Placing an eval around "\\1" does seem to work. i get an error of:
>
> Warning: Unexpected character in input: '\' (ASCII=92) state=1
> in Eval
> code on line 1
>
> i appreciate any suggestions.
>
> --
> ~darcy w. christ
> Elegant Communications Inc.
> 416.362.9772 x222 | 416.362.8324 fax
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/