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 Link to comment https://forums.phpfreaks.com/topic/61620-need-an-example/ 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> Link to comment https://forums.phpfreaks.com/topic/61620-need-an-example/#findComment-306879 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>. Link to comment https://forums.phpfreaks.com/topic/61620-need-an-example/#findComment-307978 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> Link to comment https://forums.phpfreaks.com/topic/61620-need-an-example/#findComment-308089 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.