I am having trouble with my regular expressions and am not sure why. I am trying to get the most recent discussion (not under the featured section) on this (http://www.grasshopper3d.com/forum/cate ... orCategory) forum page then upload all the .gh attachments to a MySQL database.
1) I used $discussions_start to select everything below the heading in quotes in the code below (this way I rule out the discussions in the "featured" section of the page)
2) I selected URLs that start with http://www.grasshopper3d.com/forum/topics with any words or numbers or dashes following (Ex. http://www.grasshopper3d.com/forum/topi ... -questions)
3) Then I find all attachment URLS http://www.grasshopper3d.com/forum/atta ... dedFile%3A with any words, numbers or dashes following. (Ex. http://www.grasshopper3d.com/forum/atta ... e%3A507998)
I know the problem is my reg ex's because I used this tool (http://regex.larsolavtorvik.com) and am not getting what I expect but dont get why.
Code: Select all
<?PHP
if(isset($_POST['Display'])) {
$url = "http://www.grasshopper3d.com/forum/categories/sample-and-example-files/listForCategory";
$url_result_string = file_get_contents($url);
$discussions_start = preg_match(/<TH CLASS="XG_LIGHTBORDER">DISCUSSIONS</TH>.*/i ,$url_result_string);
$discussions_url = preg_match(/http:\/\/www\.grasshopper3d\.com\/forum\/topics\/(\w+|\d*|\-*)+/i, $discussions_start);
$discussions_url_string = file_get_contents(&discussions_url);
$gh_file_url = preg_match_all(/http:\/\/www.grasshopper3d.com\/forum\/attachment\/download\?id=2985220%3AUploadedFile%3A/d+/ , $discusion_url_string);
//then load $gh_file into MySQL
}
?>McK