in reply to Re^2: Regex split string into n-length (\K 5.010)
in thread Regex split string into n-length
That adds a terminal "-" whenever the string's length is a multiple of 3:
$ perl -Mstrict -Mwarnings -E ' my @list = qw{12 123 1234 12345 123456 1234567 234 2345 23456}; for (@list) { s/\w{3}\K/-/g; say; } ' 12 123- 123-4 123-45 123-456- 123-456-7 234- 234-5 234-56
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Regex split string into n-length (\K 5.010)
by McA (Priest) on Sep 10, 2013 at 07:57 UTC |