phorcon3 Posted February 13, 2008 Share Posted February 13, 2008 here's the string <a href="/online/frame.htm?si=2m70n.1jpqGQ.1rgs6v.C**&v=1"> and i have to find /online/frame.htm?si=2m70n.1jpqGQ.1rgs6v.C**&v=1 and i tried using: <?php $html = '<a href="/online/frame.htm?si=2m70n.1jpqGQ.1rgs6v.C**&v=1">'; preg_match_all('/href="/online/frame.htm?si=(.*?)&v=1"/', $html, $match); $find = $match[1][0]; echo $find; ?> but it just wouldn't output anything. any ideas to why that is? <?php preg_match_all('/frame.htm?si=(.*?)&v=1/', $result, $matches); ?> doesn't work either. Link to comment https://forums.phpfreaks.com/topic/90993-preg_match_all/ Share on other sites More sharing options...
laffin Posted February 13, 2008 Share Posted February 13, 2008 that's cuz ya using the delimeters within the patters / # set start/end delimeter href="/online/frame.htm?si=(.*?)&v=1" # our search pattern / # end delimeter so it will just look for href=" and think everything beyond that is a optional preg parameter (not a pattern) easiest way change the delimeter @href="/online/frame.htm?si=(.*?)&v=1"@ Link to comment https://forums.phpfreaks.com/topic/90993-preg_match_all/#findComment-466360 Share on other sites More sharing options...
phorcon3 Posted February 13, 2008 Author Share Posted February 13, 2008 thanks, but it's not working either for some reason Link to comment https://forums.phpfreaks.com/topic/90993-preg_match_all/#findComment-466362 Share on other sites More sharing options...
laffin Posted February 13, 2008 Share Posted February 13, 2008 okay other problems . ? are special characters in patterns. in order to match these as literal (exact) ya need to escape them preg_match_all('@href="/online/frame\.htm\?si=(.*?)&v=1"@', $html, $match); Link to comment https://forums.phpfreaks.com/topic/90993-preg_match_all/#findComment-466365 Share on other sites More sharing options...
phorcon3 Posted February 13, 2008 Author Share Posted February 13, 2008 aaah!! lol, thanks, it worked! Link to comment https://forums.phpfreaks.com/topic/90993-preg_match_all/#findComment-466366 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.