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

This is a good idea in general, but won't work for the OP specific requirement: ABC23 will be split into ABC and 23, but split won't generate a third empty string.

For example:

$ perl -E ' say map { qq{"$_" }} split /(\d+)/ for qw[ AB23C ABC23 23 +BC ABC ]' "AB" "23" "C" "ABC" "23" "" "23" "BC" "ABC"

Replies are listed 'Best First'.
Re^3: Split with numbers
by Anonymous Monk on Nov 24, 2015 at 20:00 UTC

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

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

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

      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"