Re: [PHP] Re: Re: Re: preg_match() returns false but no documentation why
- From: paul@xxxxxxxxxxxxxxxxxxx (Paul Novitski)
- Date: Wed, 30 May 2007 21:32:55 -0700
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 .
- References:
- Re: Re: Re: preg_match() returns false but no documentation why
- From: "Jared Farrish"
- Re: Re: Re: preg_match() returns false but no documentation why
- Prev by Date: Re: [PHP] using mysql_escape_string with implode() !!
- Next by Date: Re: [PHP] using mysql_escape_string with implode() !!
- Previous by thread: Re: Re: Re: preg_match() returns false but no documentation why
- Next by thread: Re: Re: Re: Re: preg_match() returns false but no documentation why
- Index(es):
Relevant Pages
|