>>>>> "You" ==   <[EMAIL PROTECTED]> writes:

You> on page 83 of Learning Perl, they give a regex
You> example:


You>  /abc\bdef/;

You> #never matches (impossibe for a boundary there)


You> Could someone please explain this to me clearly so I
You> can actually understand word boundaries?

First, understand what anchors do.  "^" means "beginning of string",
but itself does not take up any space.  It merely "asserts" that
"at this point in the string, for this regex to match, we must
have this condition true: beginning of string".

So, can you at least see that /abc^def/ could never match?  Because
we would never be at the beginning of string after we've matched
a b c.

Now, let's look at \b in the same light.  \b says "I've got \w on one
side, and either \W or the edge of the string on the other".  It
itself is of no width; it's merely a condition like "^".  Back to
/abc\bdef/, if you're just having matched "a b c", then certainly
you've got a \w on one side (letter "c"), so for \b to match, it's
gotta have \W or edge of string on the other.  But if that's true, you
can't have a "d" next, because that's neither \W nor edge of string!

Does that help?  I think we say this differently in llama3, but the
text isn't directly in front of me, sorry.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Reply via email to