ryanfait Posted May 16, 2008 Share Posted May 16, 2008 I'm trying to pull a URL from an HTML anchor. The following regex used with preg_replace works for everything except <a href="/">. I just need it to grab the / from inside the href="". It correctly pulls out <a href="/page/">. <?php $pull_address = "/<a[\s]{1}href\=\"([\w\.0-9\/\-\%\?\=^#]{1}[\w\.0-9\/\-\%\?\=&;]+)(#[\w\.0-9\/\-\%\?\=&;]*)?\"(.*)?>/"; $loc = preg_replace($pull_address, "$1", $anchor); ?> Quote Link to comment Share on other sites More sharing options...
effigy Posted May 16, 2008 Share Posted May 16, 2008 /<a[^>]+href="(.+?)"/ 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.