* Thus wrote CPT John W. Holmes ([EMAIL PROTECTED]):
> From: "Curt Zirzow" <[EMAIL PROTECTED]>
> > * Thus wrote James Hatridge ([EMAIL PROTECTED]):
> >
> > preg_match('#\<title\>(.*)\</title\>#im', $text, $matches):
> 
> I don't think you have to escape the < and > characters, do you? Also,
> what's the 'm' modifier for? (I know what it does, why are you using it
> here?)

hm.. I did that by memory, i could of swore that those were beginning
and ending of word matching characters.  I forgot to put my disclaimer
that it was only an example and not something to be used. I spent maybe
5 seconds thinking what he is looking for.

I used the 'm' when  I should have used the 's'. 

> 
> Also, if there's ever a case where could have
> 
> <title>
> My Title
> </title>
> 
> i.e. things spread over multiple lines, then you'll need:
> 
> preg_match('#<title>(.*)</title>#is',$text,$matches);
> 
> or, even better (ungreedy)
> 
> preg_match('#<title>([^<]+)</title>#i',$text,$matches);
> 
> The 's' modifier will allow you to match the title even though it's over
> multiple lines with the first regex example. It's not needed in the second.

This has always been a confusing issue, cept now after reading php
documentation on the reg modifiers. Their description of 's' is
completely different (and easier to understand) than man perlre.

Thanks for clearing that up.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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

Reply via email to