in reply to How to split_and_pad string to n-th chars pieces with one regular expression?
Maybe I misunderstood the problem, but I'd try:
Update: missed the "empty string" part:
... $txt =~ s/(.{1,3}|^$)/sprintf"'%3s'\n",$1/ge; print $txt; ...
Regards
mwa
|
|---|