On Tue, 2008-11-18 at 00:52 -0800, howa wrote: > Hello, > > I have two strings: > > 1. abc > 2. abc& > > > The line of string might end with "&" or not, so I use the expression: > > (.*)[$&] > > > Why it didn't work out?
Inside the [] the meta-character loose their meaning. Only ^ and - have special meaning. You have to use | instead. #!/usr/bin/perl use strict; use warnings; while( <DATA> ){ chomp; if( /abc(\&|$)/ ){ print "$_\n"; } } __DATA__ abc def abc& foo bar sdfgjd sdfgs -- Just my 0.00000002 million dollars worth, Shawn The map is not the territory, the dossier is not the person, the model is not reality, and the universe is indifferent to your beliefs. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/