in reply to Re: Quantified Regex Replacement
in thread Quantified Regex Replacement
Hi, Try this,
while(<DATA>){ s/\]([ATCG]*)\[/'N' x length($1)/e; print $_; } __DATA__ TG[CCC]CC[TTT] TG[CCC][TTT] TG[CCAAATTT] Respective Output is: TG[CCCNNTTT] TG[CCCTTT] TG[CCAAATTT]
Updated: monkfan, Try below code for your second question.
while(<DATA>){ s/\]([ATCG]*)\[/my $a = $1; $a =~ s![^C]+!'N' x length($1)!e; $a/e; print $_; } __DATA__ TG[CCC]CC[TTT] Respective Output is: TG[CCCCCTTT]
Regards,
Velusamy R.
|
|---|