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