Hello all,

Thank you for the time.  I guess that this foray into lookaround assertions
was bust.  ;0) I am using Parse::RecDescent and I realized that I could use
the
order of Rules to ensure that if I *wasn't* looking at either a \\n or a \"
then I would have a bare \ that a simple Production could deal with.

Thanks (Mr $) to all!

chahn

-----Original Message-----
From: $Bill Luebkert [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 14, 2004 7:37 PM
To: Christopher Hahn
Cc: [EMAIL PROTECTED]
Subject: Re: regexp question

Christopher Hahn wrote:

> $Bill,
> 
> The (?: ) construct may be non-capturing, but it does eat text from 
> the buffer (sic)
> 
> ...and, besides, when I ran it I saw this:
> =====================================
> 1: asd asdf adf asd \n asd adf
> 2: asd asdf adf asd \n asd adf
> 3: asd asdf adf asd  asd adf
> =====================================
> 
> where I need to see something like this:
> =====================================
> 1: asd asdf adf asd
> 2: asd asdf adf asd \n asd adf
> 3: asd asdf adf asd  asd adf
> 4: asd asdf adf asd  asd adf " ad dasf \n dsaf 
> =====================================
> 
> i.e. \n should pass through, where \\n or \" should not.

Does a non-greedy match help (also - I was missing an escape or two on the
\\n):

foreach (
  '1: asd asdf adf asd \\\\n asd adf \" ad dasf dsaf ',
  '2: asd asdf adf asd \n asd adf \" ad dasf dsaf ',
  '3: asd asdf adf asd  asd adf \" ad dasf \\\\n dsaf ',
  '4: asd asdf adf asd  asd adf " ad dasf \n dsaf ',
  ) {
        if (/^(.*?)(?:\\\\n|\\")/) {
                print "$1\n";
        }
}

> 
> What about trying something like:
> 
>   $strval =~ m/^(( [^\\] | \\ (?! \\ (?= n)) | \\ (?! \") )*)/x;
> 
> which (or so I think ;0) collects as many characters from the 
> beginning of $str that meet these conditions (bs = backslash):
> =====================================
>    1) not a bs
> or 2) a bs that is *not* followed by a ( bs that *is* followed by a n 
> ) or 3) a bs that is *not* followed by a "
> =====================================

-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic
http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to