Re: Little regex help please...

From: Date: Mon, 13 Oct 2008 17:12:23 +0000
Subject: Re: Little regex help please...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-281827@lists.php.net to get a copy of this message
Ryan S wrote: > 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 > > > > > Take off the first / preg_match('#<title>([^<]*)<\/title>#iU',$data,$match); -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare

« previous php.general (#281827) next »