This is an example of perl regular expression greediness. check 'perldoc perlre' and search for "greediness".
You might want to use something like s/$openTag.*?$closeTag/New/g the extra '?' does not mean what you think it means when it follows a + or a * :-) Sorry for the top post. On Thu, 7 Oct 2004 15:45:09 +0530, Anish Kumar K. <[EMAIL PROTECTED]> wrote: > Hi > > Please anyone help me in Reg Exp. I wanted to replace "[%one_two%]" and "[%pne%]" > with the value "New" say... > I wrote the following code...I am unable to get the output as > > "This is a test for New number and New numbers." > > I am getting it as > > "This a test for New numbers." WHICH IS WRONG... > > Please let me know what to do If I need to replace in both... > > Thanks > Anish > > #!/usr/bin/perl > > $openTag='\[%'; > $closeTag='%\]'; > my $count=0; > $_= "This is a test for [%one_two%] number and [%pne%] numbers."; > > s/$openTag.*$closeTag/New/g; > > print "The new line is:::::: $_ \n"; > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>