If you want want to replace everything between the innermost occurrence of "aw ??? 
zzz" you may try this

        $str =~ s/aw.*?(?!aw)zzz/awTXTzzz/;

the '.*?(?!aw)' takes care that between 'aw' and 'zzz' anything but 'aw' will match.

Schirr


> if I have
> my $str = 'aw bcdefaw e a rt zzz kjkjkjaw qa' ;
>
> If I wish to replace everything between 'a' and 'zzz' With 'TXT'
> I do
>
> $str=~s/a[^a]+zzz/aTXTzzz/;
> This works fine.
>
> Now if I wish to replace everything between 'aw' and 'zzz' with 'TXT'
> I am not able to use
>
> $str=~s/aw[^(aw)]+zzz/awTXTzzz/;
>
> I know I can use
> $str=~s/^(.*)aw.*?zzz/$1awTXTzzz/s;
>
> But this seems to be a very untidy way beacuse In my real program $str
> is an entire file in a string and could be a very long one
>
> Is there a better way
> Thanks
> Ram


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

Reply via email to