Re: What's wrong with this code?

From: Date: Tue, 22 May 2001 11:03:18 +0000
Subject: Re: What's wrong with this code?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-53845@lists.php.net to get a copy of this message
Ahh, so you can use \\n within the regex itself...I was thinking that what was capture in the regex itself wasn't available until the "replace" part. Obviously that's not true ;) Thanks alot, everyone! One problem down, all the other one's to go :) Plutarck "Christian Reiniger" <creinig@mayn.de> wrote in message news:01052206314400.00595@chrisbig... On Tuesday 22 May 2001 05:06, Plutarck wrote: > And now one more bit. For instance to kill an onclick event I use: > > $file = preg_replace("#<(.*)onclick=\".*\"(.*)>#isU", > "<\\1\\2>", > $file); > > Which works, kinda. Problem is, consider this: > > onclick='somecode()' > > It's not caught, because it only catches double quotes. How best can I > say I want code which is between single quotes, or between double > quotes, without it choking on something like: > onclick='somecode("thisiswhereitwouldstop")'? #<(.*)onclick=(\"|').*\\2(.*)># A simple "or" combined with a backreference. And don't forget to adjust your replacement string.. -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) "Software is like sex: the best is for free" -- Linus Torvalds -- 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

« previous php.general (#53845) next »