[PHP] preg_replace: replacing using %
- by Juan
Hi all,
I'm using the function preg_replace but I cannot figure out how to make it work, the function just doesn't seem to work for me.
What I'm trying to do is to convert a string into a link if any word contains the % (percentage) character.
For instance if I have the string "go to %mysite", I'd like to convert the mysite word into a link.
I tried the following...
$data = "go to %mysite";
$result = preg_replace('/(^|[\s\.\,\:\;]+)%([A-Za-z0-9]{1,64})/e',
'\\1%<a href=#>\\2</a>', $data);
...but it doesn't work.
Any help on this would be much appreciated.
Thanks
Juan