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

Re: Regex split string into n-length

by johngg (Canon)
on Sep 10, 2013 at 10:51 UTC ( [id://1053231]=note: print w/replies, xml ) Need Help??


in reply to Regex split string into n-length

You could also use unpack.

$ perl -E ' say for map { join q{-}, unpack q{(a3)*}, $_ } qw{ 12 123 1234 12345 123456 1234567 };' 12 123 123-4 123-45 123-456 123-456-7 $

I hope this is helpful.

Cheers,

JohnGG

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1053231]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-24 01:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found