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" <[EMAIL PROTECTED]> wrote in message
01052206314400.00595@chrisbig">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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
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