esiason14 Posted September 6, 2006 Share Posted September 6, 2006 I normally don't do this, but when it come to regular expressions...I am lost. I've look at the tutorials and have tried and tried, but I cant seem to get it.I'm trying to match a block of html like this:[code] <td width="50%" class="playerbio"> <b>Height/Weight: </b> 6-6/229<br> <b>Birthdate: </b> 04/22/1983<br> <b>Birthplace: </b> Fort Smith, AR, USA<br> </td> <td width="50%" class="playerbio"> <b>Team: </b> Jacksonville Jaguars<br> <b>College: </b> Arkansas<br>[/code]anyone care to help. I will repay you with kind words ;D Link to comment https://forums.phpfreaks.com/topic/19954-match-html-block/ Share on other sites More sharing options...
Nicklas Posted September 7, 2006 Share Posted September 7, 2006 You want to match the text in bold? Link to comment https://forums.phpfreaks.com/topic/19954-match-html-block/#findComment-87486 Share on other sites More sharing options...
esiason14 Posted September 7, 2006 Author Share Posted September 7, 2006 Sorry,[code] <td width="50%" class="playerbio"> <b>Height/Weight: </b> 6-6/229<br> <b>Birthdate: </b> 04/22/1983<br> <b>Birthplace: </b> Fort Smith, AR, USA<br> </td> <td width="50%" class="playerbio"> <b>Team: </b> Jacksonville Jaguars<br> <b>College: </b> Arkansas<br>[/code]I want to match everything between the [code]</b> and <br> tags[/code]....6-6/229, 04/22/1983, Fort Smith, AR, USA, Arkansas Link to comment https://forums.phpfreaks.com/topic/19954-match-html-block/#findComment-87513 Share on other sites More sharing options...
MaaSTaaR Posted September 7, 2006 Share Posted September 7, 2006 try this :)[code=php:0]<?php $string = '<td width="50%" class="playerbio"> <b>Height/Weight: </b> 6-6/229<br> <b>Birthdate: </b> 04/22/1983<br> <b>Birthplace: </b> Fort Smith, AR, USA<br> </td> <td width="50%" class="playerbio"> <b>Team: </b> Jacksonville Jaguars<br> <b>College: </b> Arkansas<br>'; $search = "~</b>\s*(.*?)\s*<br>~ise"; $replace = "replace('\\1')"; $do_search = preg_replace($search,$replace,$string); function replace($text) { echo $text . '<br />'; }?>[/code]try this page : http://gnosis.cx/publish/programming/regular_expressions.html it's great :) Link to comment https://forums.phpfreaks.com/topic/19954-match-html-block/#findComment-87614 Share on other sites More sharing options...
Nicklas Posted September 7, 2006 Share Posted September 7, 2006 [code=php:0]preg_match_all('/(?<=<\/b>).*?(?=<br( \/)?>)/is', $string, $matches);print_r($matches);[/code] Link to comment https://forums.phpfreaks.com/topic/19954-match-html-block/#findComment-87721 Share on other sites More sharing options...
esiason14 Posted September 7, 2006 Author Share Posted September 7, 2006 Thanks for the help, guys! Link to comment https://forums.phpfreaks.com/topic/19954-match-html-block/#findComment-87788 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.