Page 1 of 1

PReg_replace,highlight_string HELP!

Posted: Mon May 16, 2005 6:08 pm
by razno
Hi guys.I need some help
I have this code

Code: Select all

$tekst=preg_replace(array('/(\[php\])(.+)(\[\/php\])/'),highlight_string($2,true),$tekst);
ANd wheni try to use it i don't get higlighted text.I get nubmer 2 in color.

How i can fix this?I was searching a lot but i can't find anything.Please help.I need this urgent

Posted: Mon May 16, 2005 6:49 pm
by evilmonkey
Your variable can't start with a number, that's one of the number one rules of programming in any language.

Posted: Tue May 17, 2005 4:51 am
by razno
This is regex.Even if i use \\2 i get the same result

Posted: Tue May 17, 2005 2:04 pm
by Chris Corbyn
The "$2" must be quoted in a string... it would actually give you errors like you have it if you have error reporting on. Same goes for "\\2"

Also... put a "?" after your ".+" because it's greedy and will match too much how you have it. You need the "s" and "e" modifier too.

Good luck!

PS: Moved to regex