tejama Posted July 24, 2007 Share Posted July 24, 2007 I need an example of a regex that will find the name 'Ortiz' and parse it so that it returns on the last number on this line (which is 16). Ortiz</a></td><td>90</td><td>330</td><td>61</td><td>106</td><td>32</td><td>0</td><td>16</td> Appreciate any help you can give me! Thanks, Tejama Quote Link to comment Share on other sites More sharing options...
effigy Posted July 25, 2007 Share Posted July 25, 2007 <pre> <?php $string = 'Ortiz</a></td><td>90</td><td>330</td><td>61</td><td>106</td><td>32</td><td>0</td><td>16</td>'; preg_match('/Ortiz.+((?<!\d)\d+)/', $string, $matches); array_shift($matches); print_r($matches); ?> </pre> Quote Link to comment Share on other sites More sharing options...
tejama Posted July 26, 2007 Author Share Posted July 26, 2007 Thanks, for the string I submitted that actually returns the proper value. However, I did leave something out. That is that the string I'm trying to parse has characters after 16 as well: Ortiz</a></td><td>90</td><td>330</td><td>61</td><td>106</td><td>32</td><td>0</td><td>16</td><td>18</td><td>20</td> So basically, I'm looking for a regex that will parse this line to return the value between the seventh set of <td>. Quote Link to comment Share on other sites More sharing options...
effigy Posted July 26, 2007 Share Posted July 26, 2007 <pre> <?php $string = 'Ortiz</a></td><td>90</td><td>330</td><td>61</td><td>106</td><td>32</td><td>0</td><td>16</td><td>18</td><td>20</td>'; preg_match('#Ortiz.*?(?:<td>.*?</td>){6}<td>(\d+)#', $string, $matches); array_shift($matches); print_r($matches); ?> </pre> 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.