View Single Post
Old 02-01-2010, 08:09 PM   #1 (permalink)
Parvus
The Wanderer
Newcomer 
 
Parvus's Avatar
 
Join Date: Aug 2008
Posts: 21
Thanks: 1
Parvus is on a distinguished road
Default preg_replace within preg_replace

Helly all,

I'll try to explain my question as short as possible.
I have [ url=javascript:document.location='http://www.google.com']test[/ url]

and I simply replace the [url part with the normal <a part, but you can see the javascript part in it. For this I would like to use a second replace.
So the first regex will be like '/[url=(.*?)]/' and change it to <a href='$1' etc., but I want to check the $1 for javascript. So my first thought was something like <a href='strip("$1"), but that won't work since php acts like $1 is a normal string ....

I have read some about the e modifier and preg_replace_callback, but i'm not finding the solution yet.

Could someone help me and show me an example of how to do this ?
Parvus is offline  
Reply With Quote