btray77 Posted November 30, 2008 Share Posted November 30, 2008 I really need to go buy that regex book, but I just don't have the time to read it lately. I'm trying to get the data between these two tags: Tag A: <table style="border-collapse: collapse;" id="table9" bordercolorlight="#FFFFFF" border="1" width="100%"> Tag B: </table> What I want is going to be in "RED". Data Sample: <b>ITEM DESCRIPTION</b></p></td> </tr> </tbody></table> </div> <div align="center"> </div> </div> <div align="left"> <table style="border-collapse: collapse;" id="table9" bordercolorlight="#FFFFFF" border="1" width="100%"> <tbody><tr> <td bgcolor="#ffffff" width="107"> <p></p></td> </tr> <tr> <td bgcolor="#941410" width="107"> <p align="right"><font color="#ffffff"><b>Gender </b></font></p></td> <td bgcolor="#ffc3bd"> MEN</td> </tr> <tr> <td bgcolor="#941410" width="107"> <p align="right"><font color="#ffffff"><b>Name </b></font></p></td> <td bgcolor="#ffc3bd"> VERSACE EAU FRAICHE by VERSACE MAN</td> </tr> <tr> <td bgcolor="#941410" width="107"> <p align="right"><font color="#ffffff"><b>Size </b></font></p></td> <td bgcolor="#ffc3bd"> 3.4 oz EDT SPRAY</td> </tr> <tr> <td bgcolor="#941410" width="107" height="24"> <p align="right"><font color="#ffffff"><b>Packaging </b></font></p></td> <td bgcolor="#ffc3bd" height="24"> BOX</td> </tr> <tr> <td bgcolor="#941410" width="107"> <p align="right"><font color="#ffffff"><b>Condition </b></font></p></td> <td bgcolor="#ffc3bd"> BRAND NEW in BOX ! </td> </tr> </tbody></table> </div> </td> </tr> <tr> <td> <p align="center"> <font style="font-size: 10pt; font-weight: 700;" color="#cc0000" face="Verdana"> Any help will be appreciated.. B Quote Link to comment https://forums.phpfreaks.com/topic/134813-regex-between-two-specific-tags/ Share on other sites More sharing options...
ddrudik Posted November 30, 2008 Share Posted November 30, 2008 <?php $sourcestring="your source string"; preg_match('~<table style="border-collapse: collapse;" id="table9" bordercolorlight="#FFFFFF" border="1" width="100%">(.*?)</table>~s',$sourcestring,$matches); echo "<pre>".print_r($matches,true); ?> Quote Link to comment https://forums.phpfreaks.com/topic/134813-regex-between-two-specific-tags/#findComment-702026 Share on other sites More sharing options...
btray77 Posted November 30, 2008 Author Share Posted November 30, 2008 Thank you for the help. it works with the demo text, but does not seem to work with the server's live text, even though it's exactly the same. I don't quite understand it. B Quote Link to comment https://forums.phpfreaks.com/topic/134813-regex-between-two-specific-tags/#findComment-702059 Share on other sites More sharing options...
ddrudik Posted November 30, 2008 Share Posted November 30, 2008 Must not be the same then. Consider providing the URL for testing. Quote Link to comment https://forums.phpfreaks.com/topic/134813-regex-between-two-specific-tags/#findComment-702089 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.