Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://654128]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2023-09-30 11:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?