Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^3: Split a string into items of constant lengthby truedfx (Monk) |
on Oct 04, 2005 at 13:40 UTC ( [id://497246]=note: print w/replies, xml ) | Need Help?? |
Yes: of course this does not take care of the case when the given string has a length that is not a multiple of 5.If you want to catch that, you can change the regex to /.{1,5}/g. Of course, depending on what it's used for, simply discarding it can be a better idea, and /.{5}/g works just fine for that.
In Section
Seekers of Perl Wisdom
|
|