Re: Regular Expression Problem
| From: | Jason Wong | Date: | Tue, 02 Jul 2002 18:30:41 +0000 |
| Subject: | Re: Regular Expression Problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-104991@lists.php.net to get a copy of this message | ||
On Wednesday 03 July 2002 01:59, Martin Clifford wrote:
> Even this:
>
> $output = preg_replace("/^[\$]{1,2}[a-zA-Z][0-9]+$/",
> "<b>\\1</b>", $var);
> echo $output;
>
> Doesn't work. It just takes whatever you put into $var, then puts it into
> $output, and outputs it to the screen.
>
> I want to change anything resembling a PHP variable, i.e. $var, $$var or
> &$var to <b>$var</b>. Any ideas on how to do that?
Don't use "" strings unless you need variable expansion.
Try:
'/^\${1,2}[ ....
... actually try RTFM, the section on variables gives you a regex definition
of acceptable PHP variables!
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
To be sure of hitting the target, shoot first and, whatever you hit,
call it the target.
*/