ivytony Posted February 25, 2008 Share Posted February 25, 2008 <?php $url = 'http://www.officedepot.com/?url=http://clickme.com?id=pA8dtfFoCs8&postrid=137588.443676&type=2&subid=0'; ?> for this above $url, I would like to get the main domwin and the part after ?url=. Now I can get the domain by using this regular expression <?php preg_match('/([^\.\/]+\.[^\/\.]+)((\/)|($))/', $url, $d); echo $domain = strtolower($d[1])."<br />"; ?> I am wondering how to use regular expression to get the part after ?url=. I apprecate your help Link to comment https://forums.phpfreaks.com/topic/92938-need-regular-expression-help-pls/ Share on other sites More sharing options...
Jessica Posted February 25, 2008 Share Posted February 25, 2008 There's a board for regular expresions: ) But if all you need is everything after ?url you can use strpos and substr. Link to comment https://forums.phpfreaks.com/topic/92938-need-regular-expression-help-pls/#findComment-476142 Share on other sites More sharing options...
ucffool Posted February 25, 2008 Share Posted February 25, 2008 Can you use parse_str() http://www.php.net/manual/en/function.parse-str.php or parse_url() http://www.php.net/manual/en/function.parse-url.php Rather than a regular expression? Link to comment https://forums.phpfreaks.com/topic/92938-need-regular-expression-help-pls/#findComment-476145 Share on other sites More sharing options...
ivytony Posted February 25, 2008 Author Share Posted February 25, 2008 I don't think I can use parse_str, because there are '&' signs in the part after $url=http://clickme.com?id=pA8dtfFoCs8&postrid=137588.443676&type=2&subid=0'; edit: I figured it out by using parse_url <?php echo parse_url($url, PHP_URL_QUERY); ?> thanks! Link to comment https://forums.phpfreaks.com/topic/92938-need-regular-expression-help-pls/#findComment-476152 Share on other sites More sharing options...
sasa Posted February 25, 2008 Share Posted February 25, 2008 preg_match patern '/\?url=(.+)$/' Link to comment https://forums.phpfreaks.com/topic/92938-need-regular-expression-help-pls/#findComment-476159 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.