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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.