Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Split with numbers

by Anonymous Monk
on Nov 24, 2015 at 20:00 UTC ( [id://1148539]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Split with numbers
in thread Split with numbers

Use of split can be stretched for the case of xyz268 ...

split /([0-9]+)/ , $string , 3

... but still fails for the case of xyz.

Replies are listed 'Best First'.
Re^4: Split with numbers
by Laurent_R (Canon) on Nov 24, 2015 at 21:02 UTC
    Yes, you're right, I did not think that specifying a limit to 3 would work properly in this case, and it does, but, as you said, it still won't work in the case of ABC:
    $ perl -E ' say map { qq{"$_"\t}} split /(\d+)/, $_, 3 for qw[ AB23C +ABC23 23BC ABC ]' "AB" "23" "C" "ABC" "23" "" "" "23" "BC" "ABC"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1148539]
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: (5)
As of 2024-04-24 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found