> Combining John's answer and a variant of Michael's:
>
>
>
> my $str = q/aw bcdefaw e a rt zzz kjkjkjaw qa/;
>
> print "$str\n";
>
> # Look for a string
>
> $str =~ s/
> (?<=aw) # Preceded by 'aw'
> ((?!aw).)*? # Not containing 'aw'
> (?=zzz) # followed by 'zzz'
>
Ramprasad wrote:
> John W. Krahn wrote:
> > Ramprasad wrote:
> >
> > > 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.
> > >
> > > N
Damn...
switch the negative lookahead with the point
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
John W. Krahn wrote:
Ramprasad wrote:
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
Michael Pohl wrote:
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.
Doesnot work
#!/usr/bin/perl
#
use strict;
my $s
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 kjkjk
Ramprasad wrote:
>
> 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 ab