I have a data in my string. This post_message_2052965 is different everytime <div id="post_message_2052965">Hello Everyone<br /> <br /> There is a good movie for you all, a good creation from Mrinal Sen. <br /> Cast:Utpal Dutt, Suhasini Muley, Shekar Chatterjee and others...<br /> Story by Banafool<br /> VCD quality, Size: 930MB<br /> <br /> Hope you will like and if so please leave your comments...</div> HTML: I want this to filter like Hello Everyone<br /> <br /> There is a good movie for you all, a good creation from Mrinal Sen. <br /> Cast:Utpal Dutt, Suhasini Muley, Shekar Chatterjee and others...<br /> Story by Banafool<br /> VCD quality, Size: 930MB<br /> <br /> Hope you will like and if so please leave your comments... HTML: As I told most important part that number changes everytime so when a preg match it it doesn't recognize how can i solve a problem like this ?
preg_match('~<div id="post_message_\d+">(.*?)</div>~s', $text, $match); echo $match[1]; PHP: This should do it.
$str = '<div id="post_message_2052965">Hello Everyone<br /><br />There is a good movie for you all, a good creation from Mrinal Sen. <br />Cast:Utpal Dutt, Suhasini Muley, Shekar Chatterjee and others...<br />Story by Banafool<br />VCD quality, Size: 930MB<br /><br />Hope you will like and if so please leave your comments...</div>'; echo strip_tags($str, '<br>'); PHP: