I want to match all the text and numbers between tags in a table...they are many table rows in the table. I've having severe trouble finding the right regex and then looping through it...Here is a sample row:

<tr class="bg2" align="right" height="17" valign="middle"><td align="left"><a href="/another/URL/757657657">J. Doe</a></td><td align="center"><a href="theurl/434343434">DDD</a></td><td align="center">DDF</td><td>3</td><td>1</td><td>0</td><td>6</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td><td>.550</td><td>.540</td><td>.540</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr>

Any help would be appreciated

    So, for example, you just want "J. Doe", "DDD", etc. ?

    Try something like this:

    $pattern = '/(?<=>)[^>]+(?=<)/s';
    preg_match_all($pattern, $html_data, $matches);
      bradgrafelman wrote:

      So, for example, you just want "J. Doe", "DDD", etc. ?

      Correct...Ok, let me give it a shot and I'll let you know if it works out. Thanks for the fast response

        No problem. I of course had to make the regexp as convoluted as possible, because a simple />(.*?)</ would have worked, but that's no fun! 🙂 If you want help interpreting the pattern, feel free to ask - I'd be glad to explain... later, because I've gotta run for now.

        Good luck!

          Ok, I guess this is the problem and I should have mentioned before. There is other html on the page. All I need is to match the specific occurences above.

          These are the parts that I want to match:
          J. Doe", "DDD", 0, 0, .550, etc. ?

          I also want to match the values at the end of the urls
          <a href="/another/URL/757657657">
          <a href="theurl/434343434"

          I know this probably makes it a lot more involved, but any hints, samples, etc you can give would be great

            Best I can think of is to do this:

            $pattern = '@<td[^>]*>(.+?)(?=</td)@s';
            preg_match_all($pattern, $test, $matches);

            $matches[1] would hold all data between TD tags... you'd just have to parse each piece to see if it also has an <a> tag as well.

              Well, this seems to work, but there has to be a better way:

              preg_match_all('@<a href="\/another\/URL\/(.*?)">(.*?)<\/a><\/td><td[^>]*><a href="theurl\/(.*?)">(.*?)<\/a><\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)</td><td[^>]*>(.*?)</td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td><td[^>]*>(.*?)<\/td>@', $input, $matches); 
              
               $count = count($matches);
                      for($i=0;$i<$count;$i++)
              
                {
                 echo "".$matches[2][$i]."....".$matches[3][$i]."....".$matches[4][$i]."....".$matches[5][$i]."....".$matches[7][$i]."....".$matches[8][$i]."....".$matches[9][$i]."....".$matches[10][$i]."....".$matches[11][$i]."....".$matches[12][$i]."....".$matches[13][$i]."....".$matches[14][$i]."....".$matches[15][$i]."....".$matches[16][$i]."....".$matches[17][$i]."....".$matches[18][$i]."....".$matches[19][$i]."....".$matches[20][$i]."....".$matches[21][$i]."....".$matches[22][$i]."....".$matches[23][$i]."....".$matches[24][$i]."....".$matches[25][$i]."....".$matches[26][$i]."<br>";
              
              }
                Write a Reply...