Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: the best way to separate a string into words

by repellent (Priest)
on Jan 19, 2009 at 19:48 UTC ( [id://737382]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $string = "   a b c  "; # note leading/trailing whitespaces
    
    my @array1 = split /\s+/, $string; # returns '', 'a', 'b', 'c' (4 item
    +s)
    my @array2 = split ' ',   $string; # returns     'a', 'b', 'c' (3 item
    +s)
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-03-29 00:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found