I'm using Duncan Mundells bbcode, in a cms, and storing the bbcode as its html counterpart in the database, so when editing a post, I've been making the html convert back to bbcode, which has been fine, until I got to urls and email,
$URLSearchString = " a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'";
//Duncan Mundells bbcode to html
$Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="$1" target="_blank">$1</a>', $Text);
//than my html to bbcode in a different function w/ errors "Unknown modifier"
$Text = preg_replace("<a href=\"([$URLSearchString]*)\" target=\"_blank\">([$URLSearchString]*)</a>", '[url]$1[/url]', $Text);
And another question... is below the proper way to reverse the bbcode back to html? It works fine, but looks like I'm doing it wrong
//bbcode to html
$Text = preg_replace("(\[b\](.+?)\[\/b])is",'<span class="bold">$1</span>',$Text);
//html to bbcode (in a different function)
$Text = preg_replace("(<span class=\"bold\">(.+?)</span>)is",'[b]$1[/b]',$Text);
Thank you