I want to change any [link]http://myplace.tld Look at my site[/link] into <a href="http://myplace.tld">Look at my site</a>.
This is done with the following code:
- - - - $string_url=eregi_replace("[link]([[:alnum:]]+)://([[:space:]]*)([[:alnum:]#?/&=])space[/link]","<a href=\"\1://\2\3\" target=\"_blank\">\4</a>", $string);
echo $string_url;
(Where $string is the input).
It seems to work, but if there are more then one [link]... ...[/link] in the input, it makes a link that goes from the first [link] to the last [/link]. In other words it goes by the first [/link] and only uses the last one, which creates a really long and strange link ;o(
Can anyone please tell me what i'm doing wrong?
I've been going trough the artikel about regex (on this site), but what i'm doing here seems to be on a higher level. Since it works if there are only one [link]... ...[/link], I guess the problem is around the [/link] (stop code).
Thanks in advance.
With kind regards
Michael Rasmussen.