Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Regex split string into n-length

by johngg (Abbot)
on Sep 10, 2013 at 10:51 UTC ( #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


Comment on Re: Regex split string into n-length
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (13)
As of 2014-08-22 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (164 votes), past polls