I'm pretty new to regex coding so I'm sure this issue is just something I'm missing in my regex and I need some help. I'm writing a web service class that queries the freedb.org search page for matches on discs. There's a CURL event that calls the search page and then the body of the request is parsed for all the links to the text files of all the discs. The regex to do that is:
Code: Select all
//$parseForLinks contains the body of the search request.
if($m = preg_match('@(?:[Hh][Tt][Tt][Pp]://)?(?:[Ww]{3}\.)?(?:freedb\.org/freedb/[A-Za-z0-9]+/[A-Za-z0-9]+/?)@',$parseForLinks,$matches)) {
print_r($matches);
}
The above code works fine but the problem I'm having is it only matches 1 link when I want all the links within the page. My initial solution to this problem was to split the body into an array (each index containing one line of the body) and then loop through each line for matches but I still only get 1 link. Is there a way to match an arbitrary amount or is my regex not correct? Please help.
Here's an example link for you to see what I'm trying to parse out.
http://www.freedb.org/freedb_search.php ... llcats=YES