I have a problem with my RegEx. I want to translate a BBCode Link like
[link=www.stackoverflow.com]Stack-Overflow[/link]
into a HTML Link like
<a href='www.stackoverflow.com'>Stack-Overflow</a>.
In my String it's possibile to make more than one link in BBCode. I Also need a function to translate the html back to BBCode.
My functions are BBCode To HTML:
$Text = preg_replace('/\[link=([^ ]+).*\](.*)\[\/link\]/', '<a href="$1">$2</a>', $Text);
HTML To BBCode:
$Text = preg_replace('/\<a href="([^ ]+).*\">(.*)\<\/a\>/Usi', '[link=$1]$2[/link]', $Text);
My Problem is with thees functions, when i have more than one Link, it doesn't work, and when i have one Link translated to HTML and i want to translate back, i have only the first character of the link.
Can everyone help me? thanks in advance