My PERL Regex aren't that good... At least I'm sure the replacement of _ isn't possible with a simple regular expression. How would you do that with your preg function?
By the way, Leo's solution with the preg_replace does work, but only if there is one link to replace. Try this:
code:
$input = "[[wiki:nl]RAM] and [[wiki:en]Does_this_work]";
Off course it should give 2 links, but it gives:
code:
<a href="http://nl.wikipedia.org/wiki/RAM] and [[wiki:en]Does_this_work">RAM] and [[wiki:en]Does_this_work</a>
My function does work there. It also works if you don't specify a language. So [[wiki]Test] is just replaced by
http://www.wikipedia.org/wiki/Test
When the string is incorrect there might be an infinite loop by the way... So it could be better.
But how would you do it with preg_replace? I can learn from it too