in reply to A regex question...
use strict; use warnings; my $string= "012345678901234567890123456789"; $string = sprintf "%5s-%5s-%5s<br>%5s-%5s-%5s",$string=~/(\d{5})/g; print $string,$/;
update: I saw Tie::Cycle earlier in this node so you could also do it this way:
-enliluse strict; use warnings; use Tie::Cycle; tie my $cycle, 'Tie::Cycle', [ qw( - - <br> ) ]; my $string= "012345678901234567890123456789"; $string =~ s/(\d{5})(?!\b)/$1$cycle/g; print $string;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: A regex question...
by thezip (Vicar) on May 05, 2003 at 19:28 UTC |