my $x = 'abc' x 10; $x =~ s/(.{4})/$1 /sg; print $x, "\n"; __END__ abca bcab cabc abca bcab cabc abca bc
If you only want to insert after word characters, you can use s/(\w{4})/$1 /g instead.
In reply to Re: How to split a string into chunks of length n or less
by moritz
in thread How to split a string into chunks of length n or less
by isync
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |