TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   preg_replace within preg_replace (http://www.talkphp.com/general/5247-preg_replace-within-preg_replace.html)

Parvus 02-01-2010 08:09 PM

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 02-02-2010 03:10 PM

And then an idea came .... I could just do a search for '/[url=(.*?)(javascript?)(.*?)]/' and replace it with '<a href=$1.$3' or something like that.
=')


All times are GMT. The time now is 08:39 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0