JSHINER Posted December 12, 2007 Share Posted December 12, 2007 Within a page there are multiple instances of the following: "<a href="javascript:launchRemote('page.asp?rid=121312213122131325528913121513255289')">Name</a>" How can I create a preg_match_all that returns the following: "<a href="www.site.com/rdetail.asp?rid=121312213122131325528913121513255289">Click Here</a> So that it pulls the "rdetail.asp?rid=121312213122131325528913121513255289" from the page. Thanks in advance for any help. Quote Link to comment Share on other sites More sharing options...
effigy Posted December 12, 2007 Share Posted December 12, 2007 <pre> <?php $data = <<<DATA <a href="javascript:launchRemote('page.asp?rid=121312213122131325528913121513255289')">Name</a> DATA; preg_match_all('/(?<=<a href="javascript:launchRemote\(\'page\.asp\?rid=)(\d+)/', $data, $matches); $matches = $matches[1]; foreach ($matches as &$match) { $match = '<a href="http://www.site.com/rdetail.asp?rid=' . $match . '">Click Here</a>'; } 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.