Go Back   Forum Care Forums > Development Reference Area > Php Development

Reply
 
LinkBack Thread Tools Display Modes
Re: Re: Re: preg_match() returns false but no documentation why
Old
  (#1)
Jared Farrish
Guest
 
Posts: n/a
Default Re: Re: Re: preg_match() returns false but no documentation why - 06-02-2007, 08:56 PM

> 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 ***ume 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." $$

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: [PHP] Re: Re: Re: preg_match() returns false but nodocumentation why
Old
  (#2)
Paul Novitski
Guest
 
Posts: n/a
Default Re: [PHP] Re: Re: Re: preg_match() returns false but nodocumentation why - 06-02-2007, 08:56 PM

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 ***ume 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
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top