i am trying to use preg_replace
on a url to an image in HTML format, and turn it into BBCode.
From: <img src="http://website.com/char/sign/Name+Surname.png">
To: [sign]Name+Surname[/sign]
Note: the filename of the png file can be just Name
, it can contain a middle name like: Name+Middlename+Surname
, it can also contain -
and %2527
like Carl-Philips
or Bob+Mc%2527Donalds
So this is what I've tried so far, but it's not doing anything. What am I doing wrong?
$source = array(
'#\<img src=\"http\:\/\/website.com\/char\/sign\/\>(.+).png\>#isU'
);
$new = array(
'[sign]$1[/sign]'
);
$text = preg_replace($source, $new, $text);