> -----Original Message-----
> From: Jim Lucas [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 13, 2008 12:13 PM
> To: Ryan S
> Cc: Eric Butera; Boyd, Todd M.; php php
> Subject: Re: [PHP] Little regex help please...
> 
> Too quick on the reply....
> 
> forgot not to escape the forward slash on the closing title tag
> 
> preg_match('#<title>([^<]*)</title>#iU',$data,$match);

That'll do, Jim. :)

I also thought it worth mentioning that by telling a catch-all character
sequence (.*) not to be "greedy", another viable solution would be this:

preg_match('#<title>(.*?)</title>#iU', $data, $match);

The ? will stop it when it reaches </title> through back-tracking.
Probably less-efficient in more complex regex patterns, but I find it
can help make the patterns more readable at-a-glance in regex-heavy code
blocks.

Sorry.. a bit OT.. and the OP has already been answered. Meh.


Todd Boyd
Web Programmer




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to