Re: Little regex help please...

From: Date: Mon, 13 Oct 2008 17:09:28 +0000
Subject: Re: Little regex help please...
Groups: php.general 
Request: Send a blank email to php-general+get-281825@lists.php.net to get a copy of this message
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

« previous php.general (#281825) next »