From: Ramprasad A Padmanabhan <[EMAIL PROTECTED]>
> I have a string
> 
> $X='#SOME_STRING END';
> 
> I want to remove the begining '#' and ending 'END' but retain
> everything in between. 
> 
> 
> This way works fine
> $X=~s/^#(.*?) END$/$1/;             ##### $X is now SOME_STRING
> 
> But this way does not 
> s/^#(?=.*) END$//;                   ###### $X is still #SOME_STRING
> END

Yes, because the regexp did not match. The lookahead doesn't move the 
pointer in the string, which means the regexp engine validated that 
it can match the .* after the #, and then tries to match ' END$' 
immediately after the #.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
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