in reply to How can I expand my substring?
In your example, what is your expected result?
Also, do the strings need to be as long as you've shown? This makes reading your example quite unwieldly. Maybe shortening each group of characters to four characters helps make the example data more understandable?
Personally, I would solve the problem exactly as you described. Replace any - followed by a B by BB, and the same for the other direction. Keep doing that as long as you can:
$string1='--NN--NNN--NN--NNN--BBB-----'; 1 while $string1 =~ s/B-/BB/ or $string1 =~ s/-B/BB/; print $string1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I expand my substring?
by Anonymous Monk on Jun 30, 2014 at 12:00 UTC | |
by Corion (Patriarch) on Jun 30, 2014 at 12:02 UTC | |
by Anonymous Monk on Jun 30, 2014 at 12:10 UTC | |
by Corion (Patriarch) on Jun 30, 2014 at 12:17 UTC | |
by Anonymous Monk on Jun 30, 2014 at 12:24 UTC | |
| |
by Anonymous Monk on Jul 22, 2014 at 13:04 UTC | |
| |
by Anonymous Monk on Jun 30, 2014 at 12:07 UTC |