Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: How can I split a string into chunks of 4 characters

by Athanasius (Cardinal)
on Dec 06, 2013 at 16:31 UTC ( [id://1066005]=note: print w/replies, xml ) Need Help??


in reply to How can I split a string into chunks of 4 characters

Use a positive look-ahead assertion, like so:

2:28 >perl -MData::Dump -we "my $s = '01234abc'; my @a = $s =~ /(?=(. +{4}))/g; dd @a;" ("0123", 1234, "234a", "34ab", "4abc") 2:29 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2026-04-20 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.