Re: What's wrong with this code?

From: Date: Tue, 22 May 2001 04:31:44 +0000
Subject: Re: What's wrong with this code?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-53809@lists.php.net to get a copy of this message
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

« previous php.general (#53809) next »