Jump to content

[SOLVED] preg_match_all


waynew

Recommended Posts

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);

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/162307-solved-preg_match_all/
Share on other sites

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+)~

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.