Jump to content

Match html block


esiason14

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.