On Jul 7, David Storrs said:

>> What the \K does is make the regex think it JUST started matching, so
>> instead of replacing a bunch of stuff plus some extra fluff with the
>> original bunch of stuff, we just say "after you've matched X, pretend you
>> started matching HERE."  It comes in handy in substitutions that look like
>>
>>   s/(A)B/$1/;
>
>Honest question: What's the advantage of doing it with the \K anchor
>as opposed to simply not matching the C<B> section at all?  (Assuming,
>of course, that you don't B<need> to match it, e.g. to disambiguate
>your match.)

Uh, you have to match the "B".  The point of the substitution is "remove
all B's that have A before them".  If A isn't constant-width, then you
can't use a look-behind.  It's silly to replace "AB" with "A", since that
requires "work".  It's easier to say "match A, then pretend you just
started matching, and replace B with nothing".

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to