![]() |
|
Syntactic Confectionery Delight | |
PerlMonks |
Re: How to split_and_pad string to n-th chars pieces with one regular expression?by Limbic~Region (Chancellor) |
on Nov 30, 2007 at 14:19 UTC ( #654114=note: print w/replies, xml ) | Need Help?? |
bdimych,
any advice? Yes - stop trying to do this in a single regular expression. While I am sure there will be a dozen correct and working solutions provided, I doubt any will be self-documenting. I also suspect anyone maintaining your code will take pause when they come across it. Why not come up with a split_by_n() function where you can pass in a string and a length and get back what you want. Heck, you could then have optional parameters for what to do with empty strings, padding or not, etc. Cheers - L~R
In Section
Seekers of Perl Wisdom
|
|