#!/usr/bin/perl use warnings; use strict; use Test::More tests => 4; sub fill { my $_ = shift; my $prefix = do { s/^(-*B?)// ; $1 }; 1 while s/-B/BB/g or s/B-/BB/g; return "$prefix$_" } is(fill('--------NNNNNNN--------NNNNN--------NNNNN------NNNNNNN------- +------BBBBB-----'), '--------NNNNNNN--------NNNNN--------NNNNN------NNNNNNNBBBBBBB +BBBBBBBBBBBBBBBB', 'test1'); is(fill('---------NNNNN-NNNNNNNNNNNNN----NNNNNNNNNNN---------BBBBBBBBB +B'), '---------NNNNN-NNNNNNNNNNNNN----NNNNNNNNNNNBBBBBBBBBBBBBBBBBB +B', 'test2'); is(fill('-------NNNNNNN-----------------BBBBBBBBBBBBBBB-------------NN +NNNNN'), '-------NNNNNNNBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBNN +NNNNN', 'test3'); is(fill('--------BBBBBBBBBBBB-------NNNNNNNNNNNNN------NNNNNN'), '--------BBBBBBBBBBBBBBBBBBBNNNNNNNNNNNNN------NNNNNN', 'test4');
In reply to Re: How can I expand my substring?
by choroba
in thread How can I expand my substring?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |