jmahdi Posted March 7, 2012 Share Posted March 7, 2012 Hi Im trying to pull N_ID=value in: <a rel="gb_page_center[626, 267]" title="narrator" href="N_Details.php?N_ID=3280" style="text-decoration: none;"> i got regex like: <a[^>]+href=\".*?\\(?:RawyID)=+(.*?)\"> but dont see it working i need a regex that will: pull N_ID and disregard the existence/inexistence of the other attributes, such as : style , rel or whatever.. thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/258466-getting-query-string-from-href-attribute/ Share on other sites More sharing options...
AyKay47 Posted March 7, 2012 Share Posted March 7, 2012 *untested* $pattern = '~<a.*?href=".+?\?N_ID=(\d+)">~'; Quote Link to comment https://forums.phpfreaks.com/topic/258466-getting-query-string-from-href-attribute/#findComment-1324862 Share on other sites More sharing options...
jmahdi Posted March 7, 2012 Author Share Posted March 7, 2012 thanks, but what about the attributes after href : style="text-decoration: none;"> as the regex does not include it as a possibility... Quote Link to comment https://forums.phpfreaks.com/topic/258466-getting-query-string-from-href-attribute/#findComment-1324864 Share on other sites More sharing options...
AyKay47 Posted March 7, 2012 Share Posted March 7, 2012 thanks, but what about the attributes after href : style="text-decoration: none;"> as the regex does not include it as a possibility... remove the end > Quote Link to comment https://forums.phpfreaks.com/topic/258466-getting-query-string-from-href-attribute/#findComment-1324865 Share on other sites More sharing options...
jmahdi Posted March 7, 2012 Author Share Posted March 7, 2012 thanks, but what about the attributes after href : style="text-decoration: none;"> as the regex does not include it as a possibility... remove the end > you mean $pattern = '~<a.*?href=".+?\?N_ID=(\d+)"~'; !? Quote Link to comment https://forums.phpfreaks.com/topic/258466-getting-query-string-from-href-attribute/#findComment-1324867 Share on other sites More sharing options...
AyKay47 Posted March 7, 2012 Share Posted March 7, 2012 this will allow anything to come before or after the href attr. Things can be added to this, depending on where its coming from. Quote Link to comment https://forums.phpfreaks.com/topic/258466-getting-query-string-from-href-attribute/#findComment-1324870 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.