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. Quote 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"@ Quote 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 Quote 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); Quote 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! Quote Link to comment https://forums.phpfreaks.com/topic/90993-preg_match_all/#findComment-466366 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.