Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How to split_and_pad string to n-th chars pieces with one regular expression?

by bdimych (Monk)
on Nov 30, 2007 at 15:00 UTC ( #654128=note: print w/replies, xml ) Need Help??


in reply to How to split_and_pad string to n-th chars pieces with one regular expression?

many thanks, it is solved,
If combine BrowserUk's and mwah's solutions, then it works fine
$x=~s/(.{1,3}|^$)\n?/sprintf"'%-3s'\n",$1/eg;
it works even on multiline strings
---
and even multiline with emptyline mixed together
$x=~s/(.{1,3}|^$)\n?/sprintf"'%-3s'\n",$1/meg;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://654128]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2018-07-16 00:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (330 votes). Check out past polls.

    Notices?