Thanks a lot for the mail... I have one more to clarify...The line you specified s/$openTag.*?$closeTag/New/g;
searches and replaces the tags with the word "New" fine.. My questions is if there is a line like $_= "This is a test for [%one_two%] number and [%pne%] numbers."; Is there in perl any operator which will help me to take the variable names separately like... one_two pne Thanks Anish ----- Original Message ----- From: "David le Blanc" <[EMAIL PROTECTED]> To: "Anish Kumar K." <[EMAIL PROTECTED]> Cc: "beginners perl" <[EMAIL PROTECTED]> Sent: Thursday, October 07, 2004 4:38 PM Subject: Re: Need Help > 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> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>