G'day hankcoder,
Welcome to the monastery.
"s/(\w{3})\B/$1-/g" does what you want:
$ perl -Mstrict -Mwarnings -E ' my @list = qw{12 123 1234 12345 123456 1234567 234 2345 23456}; for (@list) { s/(\w{3})\B/$1-/g; say; } ' 12 123 123-4 123-45 123-456 123-456-7 234 234-5 234-56
-- Ken
In reply to Re: Regex split string into n-length
by kcott
in thread Regex split string into n-length
by hankcoder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |