freeloader Posted July 28, 2007 Share Posted July 28, 2007 Hi guys, I want to crawl through userprofiles on a site, but users have the possibility to use line breaks in their profile. The profiles look like this: <td class="box_content" align="center"><img src="/images/avatars/621/620232-45f783a37ad80.jpg"></td> </tr> <tr> <td class="box_content">Blablabla line 1<br /> <br /> Line 2<br /> <a href="http://www.google.be" target="_blank">Some link</a></td> Which gives, of course, the following output: Blablabla line 1 Line 2 Some link When no line breaks are used, this is the source code: <td class="box_content" align="center"><img src="/images/avatars/644/bb6a0f2f4e868d418e652a585753f1b1.jpg"></td> </tr> <tr> <td class="box_content">Sitting around smoking my </td> What I need to extract is the profile text (everything between TD tags), best of all would be if that was stripped from any other tags to save space. My current RegEx to do this: $a=preg_match("/\b<td class=\"box_content\">.*.\b.*.td>/i",$res,$d); While this works fine when no line breaks are used, it doesn't work at all when line breaks are used. I've tried solutions with variable line breaks in the RegEx (like: \n*), but couldn't come up with any solution. Any help is welcome, thanks in advance! Link to comment https://forums.phpfreaks.com/topic/62178-regex-with-possible-multiple-line-breaks/ Share on other sites More sharing options...
freeloader Posted July 29, 2007 Author Share Posted July 29, 2007 Apparently nobody here knows the answer, any suggestions as to which forum or discussion group I could go to? Thank you Link to comment https://forums.phpfreaks.com/topic/62178-regex-with-possible-multiple-line-breaks/#findComment-309980 Share on other sites More sharing options...
freeloader Posted July 29, 2007 Author Share Posted July 29, 2007 Found it myself: $a=preg_match("/<td class=\"box_content\">.*?<\/td>/sm",$res,$d); That does the job. Link to comment https://forums.phpfreaks.com/topic/62178-regex-with-possible-multiple-line-breaks/#findComment-310212 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.