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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to