Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: problems splitting string

by mrborisguy (Hermit)
on Dec 15, 2005 at 16:04 UTC ( [id://516997]=note: print w/replies, xml ) Need Help??


in reply to problems splitting string

What I was thinking would be to have a look ahead for a number.

my $string = '1 Cat 2 Dogs 3 Hamsters'; my @animals = split /(?=\d)/, $string;

    -Bryan

Replies are listed 'Best First'.
Re^2: problems splitting string
by VSarkiss (Monsignor) on Dec 15, 2005 at 16:08 UTC

      Yep. Good catch, I noticed that, and was changing it, then I noticed you posted. I tried to update with a solution using map to take off the trailing space, but it seems VSarkiss' solution is similar to mine but more elegant, so just refer down a few posts.

          -Bryan

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-20 00:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found