This is a discussion on Re: Re: Re: preg_match() returns false but no documentation why within the PHP General forums, part of the PHP Programming Forums category; > Read the manual: All due respect, I did read it. It's just... a little dense and not practically ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
> Read the manual:
All due respect, I did read it. It's just... a little dense and not practically descriptive. Maybe it's more practical to ask, "When is it practical to use it?" It matches anything, so I assume that means you can use it to match, say, a paragraph that you can't predict or match against? One that you're looking for a pattern match on one or either end? I just look at the definition and have a hard time fitting it in. I'm looking at some examples, though, so I'm sure I'll get it. And why is it called full stop? Ok, maybe the definition doesn't make any kind of sense to me, ie, practical usage. Does it mean match anything that, say, *starts* with a pattern but ends with "whatever" (.)??? Thanks! -- Jared Farrish Intermediate Web Developer Denton, Tx Abraham Maslow: "If the only tool you have is a hammer, you tend to see every problem as a nail." $$ |
|
|||
|
Hi Jared,
At 5/30/2007 06:00 PM, Jared Farrish wrote: >>Read the manual: > >All due respect, I did read it. It's just... a little dense and not >practically descriptive. Sorry, I didn't mean to be disrespectful, I thought your question was more elementary than it was. There are, though, a ton of regular expression resources on the net. Google Is Your Friend. I just got a million hits on 'regular expression tutorial.' >Maybe it's more practical to ask, "When is it practical to use it?" > >It matches anything, so I assume that means you can use it to match, say, a >paragraph that you can't predict or match against? One that you're looking >for a pattern match on one or either end? Well, sure. It often appears as .* meaning "none or any number of any characters." Use it when you honestly don't care what it matches. Say you want to find out if the word "frog" occus in a text followed by the word "dog." You could match on: /\bfrog\b(.*\b)?dog\b/i / pattern delimiter \b word boundary frog 1st word \b word boundary ( begin subpattern ..* zero or any characters \b word boundary ) end subpattern ? zero or one instance of the preceding subpattern dog 2nd word \b word boundary / pattern delimiter i case-insensitive This guarantees that both words are bounded by word boundaries and allows any number of any characters to occur between them. (There's sort of an implicit .* before and after the pattern. Because I haven't used ^ and $ to define the beginning and end of the text, regex looks for my pattern anywhere in the text.) >And why is it called full stop? That's what the 'period' is called in British English. http://google.ca/search?q=define%3Afull+stop In English syntax "period" and "full stop" are synonymous, and the RegEx manual is throwing "dot" into the same bag. Regards, Paul __________________________ Paul Novitski Juniper Webcraft Ltd. http://juniperwebcraft.com |