Make links clickable:
$re = "/((?:http:\/\/|www\.).*)(?:\s|$)/U";
$html = preg_replace($re, '<a href="$1" target="_blank">$1</a> ', $plain);
Filter empty paragraphs (Wysiwyg sucks. So does Wordpress.):
$re = "/<(?<tag>[a-z])>(\s| |<br\s*\/*>|<(?<tag2>[a-z])>(\s| |<br\s*\/*>)*<\/\k<tag2>>)*<\/\k<tag>>/";
$html = preg_replace($re, '', $plain);
Matches:
<p> </p>
<p> </p>
<p></p>
<p> </p>
<p><br /></p>
<p><br/></p>
<p><br></p>
<p><b></b></p>
<p><b> </b></p>
<p>
<b></b>
</p>
<p>
<b></b>
</p>
<p>
<b> </b>
</p>
<b></b>
<b> </b>
<p align="center"><b> </b></p>