Re: Little regex help please...

From: Date: Mon, 13 Oct 2008 16:59:53 +0000
Subject: Re: Little regex help please...
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-281819@lists.php.net to get a copy of this message
On Mon, Oct 13, 2008 at 12:52 PM, Boyd, Todd M. <tmboyd1@ccis.edu> wrote: >> -----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("'I_Âé >> ]’e†o{Iwhttp://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("ßåh�äsÞ\ Š” > �–¢http://www.youtube.com/watch?v=oQ2dKXGAjNg"); > preg_match('#<title>([^<]*)</title>#iU', $data, $match); > $title = $match[1]; > echo $title; > ?> > > HTH, > > > Todd Boyd > Web Programmer > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > You can also escape the / like \/.

« previous php.general (#281819) next »