Or possibly:
say join "-", split /\w{1,3}\K/ for @list;With this list:
my @list = qw (12 123 1234 12345 123456 1234567 234 2345 23456);this gives the following output:
12 123 123-4 123-45 123-456 123-456-7 234 234-5 234-56
In reply to Re: Regex split string into n-length
by Laurent_R
in thread Regex split string into n-length
by hankcoder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |