Re: Re: Re: preg_match() returns false but no documentation why

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-31-2007
Jared Farrish
 
Posts: n/a
Default Re: Re: Re: preg_match() returns false but no documentation why

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

Reply With Quote
  #2 (permalink)  
Old 05-31-2007
Paul Novitski
 
Posts: n/a
Default Re: [PHP] Re: Re: Re: preg_match() returns false but nodocumentation why

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:53 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0