You could also use unpack.
$ perl -E ' say for map { join q{-}, unpack q{(a3)*}, $_ } qw{ 12 123 1234 12345 123456 1234567 };' 12 123 123-4 123-45 123-456 123-456-7 $
I hope this is helpful.
Cheers,
JohnGG
In reply to Re: Regex split string into n-length
by johngg
in thread Regex split string into n-length
by hankcoder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |