monkfan has asked for the wisdom of the Perl Monks concerning the following question:
But when there are only 1 bracket pairs, I want to leave it intact:my $input_str1 = "TG[CCC]CC[TTT]"; # Desired result is this: my $rep1 = "TG[CCCNNTTT]"; # Two Ns replace two Cs in between ][. # Similarly my $input_str2 = "TG[CCC][TTT]"; my $rep2 = "TG[CCCTTT]";
I have this, but it doesn't work.my $input_str3 = "TG[CCAAATTT]"; # Desired result is this: my $rep3 = "TG[CCAAATTT]";
Is there a single regex stroke that can handle above situations?$str =~ s/\][ATCG]+\[/N/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Quantified Regex Replacement
by japhy (Canon) on Feb 23, 2006 at 05:42 UTC | |
by Samy_rio (Vicar) on Feb 23, 2006 at 05:54 UTC | |
by monkfan (Curate) on Feb 23, 2006 at 05:53 UTC | |
by japhy (Canon) on Feb 23, 2006 at 14:48 UTC |