--- James Edward Gray II <[EMAIL PROTECTED]>
wrote:
> On Mar 10, 2004, at 10:20 AM, Stuart White wrote:
> 
> > Geez, I can't recall them covering (?: ) in my
> > books...D'oh!
> 
> It may not have.  It's not super common to see it
> thrown about.  Most 
> people just use (...), I would guess.
> 

Ahh, ok.  So, like you said, (?: ) is just for
grouping things.  I can see how that might be useful. 
Thanks.


> > The part about it grouping and
> > capturing things makes sense, as it's the "cousin"
> of
> > ( ).  The part about being able to include the |'s
> > doesn't.  I found out, without knowing at the
> time,
> > that the parentheses breakdown with |'s.  I didn't
> > know it at the time, but when I put the ORs in the
> > parentheses and ran the program, I just got the
> > command prompt, no output.
> 
> Hmm. this still sounds a little confused.  

When I look at your regex, I think now that perhaps it
wasn't the ( ) that were written incorrectly by me,
but rather, my mistake in not accounting for the
digits in the brackets where the Team is, or the .+
instead of just the . in between $2 and $3.  this
makes sense, because in Beginning Perl, it has quite a
few examples of | within ( ), which is why I didn't
think it'd be a problem in the first place.

Let's us
> another example:
> 

The second regex:

if (m/\[([A-Z0-9 -]+)\](\w+).+
(Steal|Assist|Block|replaced by):? (\w+)/) 

is what I want.  This example makes sense too. 

 
> Notice that they are nearly identical matches, I
> just changed the 
> (?:...) to (...) in the second one.  They function
> the same, the 
> variables set by the expression is the only
> difference.  (?:...) 
> doesn't set a variable.
> 

Got it.

> Your other confusion seems to be the | character. 
> You seem to think 
> it's a Perl or symbol.  Not true.  We're inside a
> regex here, gotta 
> switch thinking.  Regex knowledge in, Perl out.  |
> is a regex 
> alternation character, which pretty much means find
> this or this, as 
> expected.  That's probably why the symbol was
> chosen, looks like the or 
> operators of many languages.  However, note that &
> isn't significant in 
> a regex.
> 

Yup, simple mistake.  It's been awhile since I read
about | in regex, but I remember now that it is an
alternation character.  I certainly did get confused
in my last post though.  Thanks for the clarification.

> Now, let's get to why | needs the (?:...) or (...)
> around it.  If they 
> weren't there, my regex would read like this:
> 

This part I understood.  I was confused before because
I thought that (...) broke down when | was used, and
that to circumvent that, one would use (?:...)
instead.

> You might take a trip back to the regex section of
> your books, if | is 
> new to you.  It's regex 101 and I would be super
> surprised if it isn't 
> covered.
> 

It's covered.  I'll be looking at that at lunchtime. 
Thanks.

> James
> 


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to