On Tuesday, July 2, 2002, at 01:40  PM, Martin Clifford wrote:

> I'm trying to get this darn eregi_replace() to work, but it doesn't 
> produce any results at all.
>
> I want it to find all occurances of PHP variables.  Here is the regexp
>
> $output = eregi_replace("^[\$]{1,2}[a-zA-Z][0-9]+$", "<b>\\1</b>", 
> $var);
>
> As you might guess this is for a syntax highlighting function I am 
> trying to write.  Anyone have any ideas why it's not working?  Please 
> copy me directly, as I'm on the digest.  Thanks!

I prefer the PCRE regex syntax, this should do it:

$output = preg_replace('!^\${1,2}\w+$!', "<b>$1</b>", $var);

because "\w" is the same as "[A-Za-z0-9_]" (though perhaps it is in 
POSIX regexes too).


Erik




----

Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to