waynew Posted June 16, 2009 Share Posted June 16, 2009 Having a problem. I'm crap at regex. I'm using cURL which is returning me a string from a visited webpage. I'm trying scrape MemberIds: The member ids look like so in the returned string (checked the source of the webpage too) /Profile.jsp?MemberId=4394229250 The Id can be any length, as long as its a number. Was trying this: but it was only returning the /Profile.jsp?MemberId= part and not the number. $pattern = "/Profile\.jsp\?MemberId=(.*?)/"; preg_match_all($pattern,$string,$matches); Quote Link to comment https://forums.phpfreaks.com/topic/162307-solved-preg_match_all/ Share on other sites More sharing options...
waynew Posted June 16, 2009 Author Share Posted June 16, 2009 Also tried: $pattern = "~/Profile\.jsp\?MemberId=\d+$~"; But I am literally guessing. Quote Link to comment https://forums.phpfreaks.com/topic/162307-solved-preg_match_all/#findComment-856677 Share on other sites More sharing options...
thebadbad Posted June 16, 2009 Share Posted June 16, 2009 You solved it? If not, try removing the dollar sign from your latest pattern - it matches at the end of the haystack, and that's not where the member IDs are, I guess (and only one match would be possible there). If you want to capture the IDs in an array in $matches[1], surround \d+ in parentheses. ~/Profile\.jsp\?MemberId=(\d+)~ Quote Link to comment https://forums.phpfreaks.com/topic/162307-solved-preg_match_all/#findComment-857087 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.