Re: regular expression replacement

2003-07-12 Thread Michael Pohl
> 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' >

Re: regular expression replacement

2003-07-12 Thread Rob Dixon
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

Re: regular expression replacement

2003-07-12 Thread Michael Pohl
Damn... switch the negative lookahead with the point -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: regular expression replacement

2003-07-12 Thread Ramprasad
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

Re: regular expression replacement

2003-07-12 Thread Ramprasad
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

Re: regular expression replacement

2003-07-12 Thread Michael Pohl
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

Re: regular expression replacement

2003-07-12 Thread John W. Krahn
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