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 Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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 :) Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
esiason14 Posted September 7, 2006 Author Share Posted September 7, 2006 Thanks for the help, guys! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.