-----Original Message----- From: Ryan S [mailto:genphp@xxxxxxxxx] Sent: 13 October 2008 07:09 PM To: Eric Butera; Boyd, Todd M. Cc: php php Subject: Re: Little regex help please... Hey Todd, Eric, Thanks for replying. > I don't believe you need both the / and the # for delimiters in your > RegEx. Try using just # (since / is actually going to be in the text > you're searching for) like this: > > <?php > $data = > file_get_contents("http://www.youtube.com/watch?v=oQ2dKXGAjNg"); > preg_match('#<title>([^<]*)</title>#iU', $data, $match); > $title = $match[1]; > echo $title; > ?> > > > You can also escape the / like \/. Ok, I changed it to: <?php $data = file_get_contents("http://www.youtube.com/watch?v=oQ2dKXGAjNg"); preg_match('/#<title>([^<]*)<\/title>#iU',$data,$match); $title=$match[1]; echo $title; ?> And this is the error i am getting: Warning: preg_match() [function.preg-match]: No ending delimiter '/' found in C:\wamp\www\ezee\tests\get_remote_title.php on line 3 >> Sorry forgot to include the list in my post to you Here is another solution if you don't want to play around too much with regex: <?php $data = file_get_contents("http://www.youtube.com/watch?v=oQ2dKXGAjNg"); $strt = strpos($data,"<title>")+7; $end = strpos($data,"</title>"); $len = $end - $strt; $title= substr($data,$strt,$len); echo $title ?> Produces: "YouTube - REALLY funny ad" As mentioned, you can probably "neaten" this up a bit....regex may be too complex for the simple requirement needed ? But for fun, it will be nice to see get if preg_match can do it at some stage :-) Regards, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php