Try this one... $str = "AABBE[TH]AODD[AAAB]AQA"; $str =~ s/\[[A-Z]*\]/N/g; print "$str\n\n";
+------------------------------------------ | José J. Cintrón - <[EMAIL PROTECTED]> +------------------------------------------ > -----Original Message----- > From: Edward Wijaya [mailto:[EMAIL PROTECTED] > Sent: Tuesday, November 22, 2005 10:22 > To: beginners@perl.org > Subject: Replacing a Bracketed String with "N" > > Hi, > > Is there a fast way to replace string like this: > > > $str1 = "ATC[TG]CC"; > # into > $ans_str1 = "ATCNCC"; > > #and > > $str2 ="ATC[TG]CCGC[ACTG]"; > #into > $ans_str2="ATCNCCGCN"; > > > Thus, the position of the bracket can be in any positions > with any number, and number of strings enclosed by the > bracket can consist up to 4 bases, i.e. [ATCG]. > > -- > Regards, > Edward WIJAYA > SINGAPORE > > > > -- > 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>