RE: [PHP] Little regex help please...

From: Date: Mon, 13 Oct 2008 16:52:43 +0000
Subject: RE: [PHP] Little regex help please...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-281816@lists.php.net to get a copy of this message
> -----Original Message----- > From: Ryan S [mailto:genphp@yahoo.com] > Sent: Monday, October 13, 2008 11:33 AM > To: php php > Subject: [PHP] Little regex help please... > > Hello! > > Here's a regex that I got off the web that I am trying to modify for my > needs, I suck at regex so desperately need some help. > > Basically, am trying to get a remote webpage and get the value between > the <title> tags, note that it should get the values regardless if > <title> is upper or lower case (case insensitive) > > <?php > $data = > > file_get_contents("http://www.youtube.com/watch?v=oQ2dKXGAjNg"); > preg_match('/#<title>([^<]*)</title>#/iU',$data,$match); > $title=$match[1]; > echo $title; > ?> > > This is the error that i am getting when running the above: > > Warning: preg_match() [function.preg-match]: Unknown modifier 't' in > C:\wamp\www\ezee\tests\get > _remote_title.php on line 3 Ryan, 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; ?> HTH, Todd Boyd Web Programmer

« previous php.general (#281816) next »