Possible Duplicate:
How to parse and process HTML with PHP?
Can somebody help me to find a solution to parse text which has HTML and regular text. For example
This is my awesome <b>text</b>. Now <a href="http://google.com">starts</a> a new line...
<img src="http://example.com/image.png"/><br>
<br>
I push news to http://twitter.com .
This should become
This is my awesome <b>text</b>. Now <a href="http://google.com">starts</a> a new line...<br>
<br>
<img src="http://example.com/image.png"/><br>
<br>
I push news to <a href="http://twitter.com">twitter.com</a> .
I'm searching mainly for a magic regex replace function...At the moment I do
$text = preg_replace("@(src|href)=\"https?://@i",'\\1="', $description);
$text = nl2br(preg_replace("@(((f|ht)tp:\/\/)[^\"\'\>\s]+)@",'<a href="\\1" target="_blank">\\1</a>', $text));