Shortest program to split a string at non-digits without RegExps

EDIT: If you're using Lisp, I have given some guidelines at the bottom in counting bytes.

Objective: Make the shortest function that splits a string at non-digits and returns an array consisting of only digits in each string, without the use of any regular expressions. Leading zeroes are to be included in each string.

Current Standings (separated in categories):

• C/C++/C#/Java: 68 (C) ....
• GolfScript/APL/J: 13 (APL)
• All others: 17 (Bash, uses tr), 24 (Ruby)

Rules:

(I apologize for the lengthiness)

1. The format must be as a function with a single string argument. Up to two additional arguments may be added if necessary for the proper return of the array (e.g. sh/csh/DOS Batch needs an extra variable reference to return, etc.).
2. The primary function declaration doesn't count, and nor does importing other standard libraries. #includes, imports, and usings don't count. Everything else does. This does include #defines and helper functions. Sorry for the confusion. Refer to this as a helpful guide as to what does/does not count (written in C-style syntax)
// doesn't count toward total, may be omitted unless
// non-obvious, like half of Java's standard library.
#include <stdio.h>

import some.builtin.Class // doesn't count, see above

#define printf p // counts towards total

/* Any other preprocessor directives, etc. count. */

int i = 0; // counts

someFunction(); // counts

char[][] myMainSplitFunction(char[][] array) { // doesn't count
// Everything in here counts
return returnArray; // Even this counts.
} // doesn't count

/* Everything in here counts, including the declaration */
char[][] someHelperFunction(char[] string) {
// stuff
} // even this counts

3. The output must be a string array or similar (Array lists in Java and similar are acceptable). Examples of accepted output: String[], char[][], Array, List, and Array (object).
4. The array must contain only contain variable-length string primitives or string objects. No empty strings should be present in the return, with the exception below. Note: the strings are to contain a string of consecutive matches, such as the example input and output below.
5. If there are no matches, then the function body should return null, an empty array/list, or an array/list containing an empty string.
6. No external libraries allowed.
7. DOS line endings count as one byte, not two (already covered in meta, but needs emphasized)
8. And the biggest rule here: no regular expressions allowed.

This is a question, so smallest size wins. Good luck!

And here are some example inputs and outputs (with C-style escapes):

Input:  "abc123def456"
Output: ["123", "456"]

Input:  "aitew034snk582:3c"
Output: ["034", "582", "3"]

Input:  "as5493tax54\\430-52@g9.fc"
Output: ["5493", "54", "430", "52", "9"]

Input:  "sasprs]tore\"re\\forz"
Output: null, [], [""], or similar


Guidelines for Lisp

Here's what does and doesn't count in Lisp dialects:

;;; Option 1

(defun extract-strings (a b) ; Doesn't count
(stuff) ;;; Everything in here counts
) ; Doesn't count

;;; Option 2

(defun extract-strings (string &aux (start 0) (end 0)) ; Doesn't count
(stuff) ;;; Everything in here counts
) ; Doesn't count.

All other lambdas fully count towards the byte count.

• Wasn't this asked before? – Ismael Miguel Feb 23 '14 at 6:02
• Yes, but I re-asked it on Meta and made substantial edits to it before posting it again here. Because of this, it shouldn't be classified as a duplicate (the other related one should be closed if not already). – Isiah Meadows Feb 23 '14 at 6:06
• Shouldn't your "golf" be posted as an answer? – MrWhite Feb 23 '14 at 10:57
• Sorry, but -1 for disallowing GolfScript. All languages should be allowed. – Doorknob Feb 23 '14 at 18:09
• @Doorknob That's true, but I also understand the OP's feelings. People should have a chance to compete even if they don't speak GolfScript, J, or APL (and I'm guilty of perusing the latter in these competitions.) Can you give a look at my proposal in the thread he linked to? – Tobia Feb 23 '14 at 19:45

APL, 13 chars

(or 28 / 30 bytes, read below)

{⍵⊂⍨⍵∊∊⍕¨⍳10}


I see you've banned GolfScript from your question. I understand your sentiment, but I hope this community won't eventually ban APL, because it's a truly remarkable programming language with a long history, not to mention a lot of fun to code in. Maybe it could just be scored differently, if people feel it's competing unfairly. I'll post my thoughts on this matter to that thread you've linked.

On that same token, I've always added a footnote to my APL posts, claiming that APL could be scored as 1 char = 1 byte. My claim rests on the fact that a few (mostly commercial) APL implementations still support their own legacy single-byte encoding, with the APL symbols mapped to the upper 128 byte values. But maybe this is too much of a stretch, in which case you may want to score this entry as 28 bytes in UTF-16 or 30 bytes in UTF-8.

Explanation

{        ⍳10}  make an array of naturals from 1 to 10
⍕¨      convert each number into a string
∊        concatenate the strings into one (it doesn't matter that there are two 1s)
⍵∊         test which chars from the argument are contained in the digit string
⍵⊂⍨           use it to perform a partitioned enclose, which splits the string as needed


Examples

      {⍵⊂⍨⍵∊∊⍕¨⍳10} 'ab5c0x'
5  0
{⍵⊂⍨⍵∊∊⍕¨⍳10}  'z526ks4f.;8]\p'
526  4  8


The default output format for an array of strings does not make it clear how many strings are there in the array, nor how many blanks. But a quick manipulation to add quotes should make it clear enough:

      {q,⍵,q←'"'}¨ {⍵⊂⍨⍵∊∊⍕¨⍳10} 'ab5c0x'
"5"  "0"
{q,⍵,q←'"'}¨ {⍵⊂⍨⍵∊∊⍕¨⍳10}  'z526ks4f.;8]\p'
"526"  "4"  "8"

• Regarding your comment, I think that for other languages compete fairly with "shorthand" ones one should count each symbol in the other languages as one char. For example, my Mathematica solution posted here should be counted as 7 (more or less). Designing a language with compressed tokens is not merit at all, I think. – Dr. belisarius Feb 23 '14 at 21:13
• Could you provide a hex dump of your golf? I can't read some of the characters. – Isiah Meadows Feb 24 '14 at 12:22
• @impinball How would the hexdump help you? It's not like you would see what is being done. – mniip Feb 24 '14 at 12:27
• @impinball the APL code is {omega enclose commute omega epsilon epsilon format each iota 10}. If you need the unicode values you can just copy and paste it to any online tool, even if you can't see the characters (which is strange, as most modern Unicode fonts have the APL symbols) In any case what you get is this {\u2375\u2282\u2368\u2375\u220a\u220a\u2355\u00a8\u237310} (mind the last "10" which is not part of the escape sequence) – Tobia Feb 24 '14 at 15:24
• Instead of ∊⍕¨⍳10, couldn't you just use ⎕D? That should be the constant '0123456789'. Dyalog APL at the very least supports it, and so does NARS2000. – marinus Nov 11 '14 at 12:25

Python 47

Implementation

f=lambda s:"".join([' ',e][e.isdigit()]for e in s).split()


Demo

>>> sample=["abc123def456","aitew034snk582:3c","as5493tax54\\430-52@g9.fc","sasprs]tore\"re\\forz"]
>>> [f(data) for data in sample]
[['123', '456'], ['034', '582', '3'], ['5493', '54', '430', '52', '9'], []]


Algorithm

Convert each non-digit character to space and then split the resultant string. A simple and clear approach.

And a fun solution with itertools (71 characters)

f1=lambda s:[''.join(v)for k,v in __import__("itertools").groupby(s,key=str.isdigit)][::2]


Ruby, 70

f=->(s){s.chars.chunk{|c|c.to_i.to_s==c}.select{|e|e[0]}.transpose[1]}


Online Version for testing

Since converting any non-digit character to an int returns 0 in Ruby (with to_i), converting every char to int and back to char is the non-regex way to check for a digit...

• You can also do a ('0'..'9').member? for every char, but what you did is shorter already – fgp Feb 23 '14 at 22:50
• You are definitely right - I should have said: "a" way ;) – David Herrmann Feb 24 '14 at 8:25

bash, 26 (function contents: 22 + array assignment overhead 4)

This isn't going to beat the other bash answer, but its interesting because it might make you double-take:

f()(echo ${1//+([!0-9])/ })  Usage is: $ a=(f "ab5c0x"); echo ${a[@]} 5 0$ a=(f "z526ks4f.;8]\p"); echo ${a[@]} 526 4 8$


At the first quick glance, //+([!0-9])/  looks a lot like a regexp substitution, but it isn't. It is a bash parameter expansion, which follows pattern-matching rules, instead of regular expression rules.

Returning true bash array types from bash functions is a pain, so I chose to return a space-delimited list instead, then convert to an array in an array assignment outside of the function call. So in the interests of fairness, I feel the ( ) around the function call should be included in my score.

Mathematica 32

StringCases[#,DigitCharacter..]&


Usage

inps ={"abc123def456", "aitew034snk582:3c", "as5493tax54\\430-52@g9.fc",
"sasprs]tore\"re\\forz"}
StringCases[#,DigitCharacter..]&/@inps

{{"123", "456"},
{"034", "582", "3"},
{"5493", "54", "430", "52", "9"},
{}
}


The equivalent using regexes is much longer!:

StringCases[#, RegularExpression["[0-9]+"]] &

• Mathematica sucks at regex. – CalculatorFeline Apr 27 '16 at 19:26

Bash, 21 bytes 17/21 bytes (improved by DigitalTrauma)

Building a space-separated list with tr

function split() {
tr -c 0-9 \ <<E
$1 E }  replaces any non digit by a space Usage $ for N in $(split 'abc123def456'); do echo$N; done
123
456


Edit

as pointed by the comments below, the code can be stripped down to 17 bytes:

function split() (tr -c 0-9 \ <<<$1)  and as the result is not stricly speaking a Bash array, the usage should be a=(split "abc123def456"); echo${a[@]}


and the extra () should be counted

• Gah you beat me to it! But why not use a here-string instead of a here-document? Also you can save a newline at the end of the function content you use (blah) instead of {blah;}: split()(tr -c 0-9 \ <<<$1). That way your function body is only 17 chars. – Digital Trauma Feb 24 '14 at 18:25 • Your function returns a "space-separated list" instead of an array. Certainly returning true arrays from bash function is awkward, but you could at least assign the result of your function to an array in your usage: a=($(split "12 3a bc123")); echo ${a[@]}. It could be argued that "($())" be counted in your score – Digital Trauma Feb 24 '14 at 18:29
• Before exploring the tr approach, I tried doing this with a parameter expansion. tr is definitely the better approach for golfing purposes. – Digital Trauma Feb 24 '14 at 18:45
• Have you tried surrounding the tr with the expansion operator? It would come out to something like ($(tr...)), and where the function declaration doesn't count, the outer parentheses wouldn't count against you. It would only be the command substitution part. – Isiah Meadows Feb 25 '14 at 5:40 • I don't see how this should be working, but I'm not fluent in Bash arrays though. Anyway, the () construct is 1-char better than the ($()) one and shall be prefered. – Coaumdio Feb 25 '14 at 9:23

Smalltalk (Smalltalk/X), 81

f := [:s|s asCollectionOfSubCollectionsSeparatedByAnyForWhich:[:ch|ch isDigit not]]


f value:'abc123def456' -> OrderedCollection('123' '456')

f value:'aitew034snk582:3c' -> OrderedCollection('034' '582' '3')

f value:'as5493tax54\430-52@g9.fc' -> OrderedCollection('5493' '54' '430' '52' '9')

f value:'sasprs]tore\"re\forz' -> OrderedCollection()

sigh - Smalltalk has a tendency to use veeeery long function names...

• Is that a function name? o__O – Tobia Feb 23 '14 at 19:39
• @tobia Apparently... – Isiah Meadows Feb 25 '14 at 5:49
• asCollectionOfSubCollectionsSeparatedByAnyForWhich ಠ_ಠ This name is too long – TuxCrafting Jun 19 '16 at 21:02

R, 81

f=function(x){
s=strsplit(x,"",T)[[1]]
i=s%in%0:9
split(s,c(0,cumsum(!!diff(i))))[c(i[1],!i[1])]
}


The function accepts a string and returns a list of strings.

Examples:

> f("abc123def456")
$1 [1] "1" "2" "3"$3
[1] "4" "5" "6"


-

> f("aitew034snk582:3c")
$1 [1] "0" "3" "4"$3
[1] "5" "8" "2"

$5 [1] "3"  - > f("as5493tax54\\430-52@g9.fc")$1
[1] "5" "4" "9" "3"

$3 [1] "5" "4"$5
[1] "4" "3" "0"

$7 [1] "5" "2"$9
[1] "9"


-

> f("sasprs]tore\"re\\forz")
$<NA> NULL  Note: $x is the name of the list element.

Perl, 53

Edit: on no matches, sub now returns list with empty string (instead of empty list) as required.

It also avoids splitting on single space character, as it triggers 'split on any white-space' behavior, which probably violates the rules. I could use / / delimiter, which would split on single space, but paradoxically it would look like using regexp pattern. I could use unpack at the cost of some extra characters and so get rid of split controversy altogether, but I think that, what I finish with, splitting on a literal character (other than space) is OK.

$i=0;while($i<strlen($a)){!is_numeric($a[$i])&&$a[$i]='-';$i++;}return array_filter(explode('-',$a),function($v){return!empty($v);}); }  • You can shorten it by leaving out the callback at array_filter. This will automatically remove all entries which are false when they're casted to booleans. – kelunik Apr 20 '14 at 15:54 • @kelunik that would filter out 0s as well – Einacio Apr 21 '14 at 11:35 C, 158 #define p printf char s[100],c;int z,i;int main(){while(c=getchar())s[z++]=(c>47&&c<58)*c;p("[");for(;i<z;i++)if(s[i]){p("\"");while(s[i])p("%c",s[i++]);p("\",");}p("]");}  Since C doesnt have array print functions built-in I had to do that work on my own so I apologive that there is a final comma in every output. Essentially what that code does is it reads the string if it is not a digit it replaces it with '\0' and then I just loop through the code and print out all of the chains of digits.(EOF=0) Input: ab5c0x Output: ["5","0",] Input: z526ks4f.;8]\p Output: ["526","4","8",] • According to the question's rules (rule 2), you only have to count the characters in the function body. So your solution would actually be less than 170 bytes. I'm not sure if the count includes variable prototypes outside the function body, though. – grovesNL Feb 24 '14 at 8:43 • I will amend the rules on this: #defines, variable declarations, etc. will count, but the function declaration will not. – Isiah Meadows Feb 24 '14 at 15:19 • Also, last time I checked, there was a type in C notated as char[][] which is legal. If you return as that (or char**), you will be fine. – Isiah Meadows Feb 25 '14 at 4:25 • It doesn't have To be text output? I though the program was supposed to output the array in a string format – ASKASK Feb 25 '14 at 20:54 C#, 98 static string[] SplitAtNonDigits(string s) { return new string(s.Select(c=>47<c&c<58?c:',').ToArray()).Split(new[]{','},(StringSplitOptions)1); }  First, this uses the LINQ .Select() extension method to turn all non-digits into commas. string.Replace() would be preferable, since it returns a string rather than a IEnumerable<char>, but string.Replace() can only take a single char or string and can't make use of a predicate like char.IsDigit() or 47<c&c<58. As mentioned, .Select() applied to a string returns an IEnumerable<char>, so we need to turn it back into a string by turning it into an array and passing the array into the string constructor. Finally, we split the string at commas using string.Split(). (StringSplitOptions)1 is a shorter way of saying StringSplitOptions.RemoveEmptyEntries, which will automatically takes care of multiple consecutive commas and commas at the start/end of the string. • Instead of char.IsDigit(c), you can use '/'<c&&c<':' – grovesNL Feb 24 '14 at 9:07 • Good point...or even better, 47<c&&c<58. (Frankly, I'm surprised it works with numbers, but apparently it does). – BenM Feb 24 '14 at 20:17 • And I can save an extra valuable character by using a single '&' instead of a double '&&'. In C#, this still logical AND when both operands are booleans -- it only does a bitwise AND when they're integers. – BenM Feb 24 '14 at 20:31 • Nice one. I didn't know it was able to do that. – grovesNL Feb 24 '14 at 21:49 • A slightly shorter variant is to split on white space instead of ,, and then manually remove the empty items return new string(s.Select(c=>47<c&c<58?c:' ').ToArray()).Split().Where(a=>a!="").ToArray(); – VisualMelon Oct 21 '14 at 15:51 JS/Node : 168 162 147 138 Chars function n(s){ var r=[];s.split('').reduce(function(p,c){if(!isNaN(parseInt(c))){if(p)r.push([]);r[r.length-1].push(c);return 0;}return 1;},1);return r; }  Beautified version: function n(s) { var r = []; s.split('').reduce(function (p, c) { if (!isNaN(parseInt(c))) { if (p) { r.push([]); } r[r.length - 1].push(c); return 0; } return 1; }, 1); return r; }  • This question only wants the array returned, so you can remove console.log(r) and some other things – Not that Charles Feb 24 '14 at 19:47 • The function declaration doesn't count toward the score (reason is to help level the playing field) – Isiah Meadows Feb 25 '14 at 4:23 • Ok. Adjusted the score as per @impinball's comment. (Actually there are two functions declared here. Char count includes the anonymous function) – palanik Feb 25 '14 at 4:55 • It should. I updated the rules to help explain it better. – Isiah Meadows Feb 25 '14 at 5:06 • Meanwhile, came up with something better... – palanik Feb 25 '14 at 5:11 Ruby, 24 f=->s{s.tr(" -/:-~",' ').split}  Defines digits using negative space within the printable ascii range. • Function declaration doesn't count. – Isiah Meadows Feb 25 '14 at 4:22 php, 204 function s($x){$a=str_split($x);$c=-1;$o=array();
for($i= 0;$i<count($a);$i++){if(ord($a[$i])>=48&&ord($a[$i])<=57)
{$c++;$o[$c]=array();}while(ord($a[$i])>=48&&ord($a[$i])<=57) {array_push($o[$c],$a[$i]);$i++;}}return $o;}  Descriptive Code: function splitdigits($input){

$arr = str_split($input);
$count = -1;$output = array();
for($i = 0;$i < count($arr);$i++){

if(ord($arr[$i]) >= 48 && ord($arr[$i]) <= 57){
$count++;$output[$count] = array(); } while(ord($arr[$i]) >= 48 && ord($arr[$i]) <= 57){ array_push($output[$count],$arr[$i]);$i++;
}

}

return $output; }  This is pretty long code and I'm sure there will be a much shorter php version for this code golf. This is what I could come up with in php. • there are some improvements: you can replace array() with [], array_push($output[$count],$arr[$i]); with $output[$count][]=$arr[$i];, and the ord() checks with is_numeric(). and you don't even need to split the string to iterate over its characters. also, only the inner code of the function counts, so as it is you char count is 204. – Einacio Feb 24 '14 at 16:45 • The function declaration doesn't count. Refer to rule 2 as a guide on what counts and what doesn't. – Isiah Meadows Feb 25 '14 at 5:19 Python def find_digits(_input_): a,b = [], "" for i in list(_input_): if i.isdigit(): b += i else: if b != "": a.append(b) b = "" if b != "": a.append(b) return a  Python 104 83 def f(s, o=[], c=""): for i in s: try:int(i);c+=i except:o+=[c];c="" return [i for i in o+[c] if i]  @Abhijit answer is far clever, this is just a "minified" version of what i had in mind. assert f("abc123def456") == ["123", "456"] assert f("aitew034snk582:3c") == ["034", "582", "3"] assert f("as5493tax54\\430-52@g9.fc") == ["5493", "54", "430", "52", "9"] assert f("sasprs]tore\"re\\forz") == []  This yields no output, so the code is working, if ran one by one, as some variables are defined at the declaration. • You don't have to count the function declaration, if you did. Just as a heads up – Isiah Meadows Feb 25 '14 at 5:24 PHP 98 89 As in DigitalTrauma's bash answer, this doesn't use a regex. function f($x) {
// Only the following line counts:
for($h=$i=0;sscanf(substr("a$x",$h+=$i),"%[^0-9]%[0-9]%n",$j,$s,$i)>1;)$a[]=$s;return@$a; }  Test cases: php > echo json_encode(f("abc123def456")), "\n"; ["123","456"] php > echo json_encode(f("aitew034snk582:3c")), "\n"; ["034","582","3"] php > echo json_encode(f("as5493tax54\\430-52@g9.fc")), "\n"; ["5493","54","430","52","9"] php > echo json_encode(f("sasprs]tore\"re\\forz")), "\n"; null  Haskell 31 {-# LANGUAGE OverloadedStrings #-} import Data.Char (isDigit) import Data.Text (split) f=filter(/="").split(not.isDigit)  It splits the string on all non-numeric characters and removes the empty strings generated by consecutive delimiters. VBA 210, 181 without function declaration Function t(s) Dim o() For Each c In Split(StrConv(s,64),Chr(0)) d=IsNumeric(c) If b And d Then n=n&c ElseIf d Then:ReDim Preserve o(l):b=1:n=c ElseIf b Then:b=0:o(l)=n:l=l+1:End If:Next:t=o End Function  Rebol (66 chars) remove-each n s: split s complement charset"0123456789"[empty? n]s  Ungolfed and wrapped in function declaration: f: func [s] [ remove-each n s: split s complement charset "0123456789" [empty? n] s ]  Example code in Rebol console: >> f "abc123def456" == ["123" "456"] >> f "aitew035snk582:3c" == ["035" "582" "3"] >> f "as5493tax54\\430-52@g9.fc" == ["5493" "54" "430" "52" "9"] >> f {sasprs]torer"re\\forz} == []  JavaScript, 10497 89 Golfed: Edit: When the loops walks off the end of the array, c is undefined, which is falsy and terminates the loop. 2/27: Using ?: saves the wordiness of if/else. function nums(s) { s+=l='length';r=[''];for(k=i=0;c=s[i];i++)r[k]+=+c+1?c:r[k+=!!r[k][l]]=''; r[l]--;return r }  The carriage return in the body is for readability and is not part of the solution. Ungolfed: The idea is to append each character to the last entry in the array if it is a digit and to ensure the last array entry is a string otherwise. function nums(s) { var i, e, r, c, k; k = 0; s+='x'; // ensure the input does not end with a digit r=['']; for (i=0;i<s.length;i++) { c=s[i]; if (+c+1) { // if the current character is a digit, append it to the last entry r[k] += c; } else { // otherwise, add a new entry if the last entry is not blank k+=!!r[k].length; r[k] = ''; } } r.length--; // strip the last entry, known to be blank return r; }  Javascript, 72 function f(a){ a+=".",b="",c=[];for(i in a)b=+a[i]+1?b+a[i]:b?(c.push(b),""):b;return c }  Ungolfed a+=".",b="",c=[]; //add '.' to input so we dont have to check if it ends in a digit for(i in a) b=+a[i]+1? //check if digit, add to string if it is b+a[i]: b? //if it wasnt a digit and b contains digits push it (c.push(b),""): //into the array c and clear b b; //else give me b back return c  Sample input/output console.log(f("abc123def456")); console.log(f("aitew034snk582:3c")); console.log(f("as5493tax54\\430-52@g9.fc")); console.log(f("sasprs]tore\"re\\forz")); ["123", "456"] ["034", "582", "3"] ["5493", "54", "430", "52", "9"] []  JSFiddle • I like it! Much simpler than my own. You can drop another 8 characters by replacing if(+a[i]+1)b+=a[i];else if(b)c.push(b),b="" with b=+a[i]+1?b+a[i]:b?(c.push(b),""):b. – DocMax Feb 27 '14 at 19:07 • @DocMax thx, I edited to include your suggestion :). That (c.push(b),"") seemed clever, never seen that. – Danny Feb 27 '14 at 20:35 • I had forgotten about it until I saw it used extensively earlier today in codegolf.stackexchange.com/questions/22268#22279 – DocMax Feb 27 '14 at 21:00 • That's not valid, ' ' is mistaken for 0 and it's a javascript quirk difficult to manage. Try '12 34 56' – edc65 Oct 21 '14 at 21:22 R 52 This function splits strings by character class (this is not regex! :)) class is N - numeric characters and P{N} means negation of this class. o=T means omit empty substrings. x ## [1] "wNEKbS0q7hAXRVCF6I4S" "DpqW50YfaDMURB8micYd" "gwSuYstMGi8H7gDAoHJu" require(stringi) stri_split_charclass(x,"\\P{N}",o=T) ## [[1]] ## [1] "0" "7" "6" "4" ## [[2]] ## [1] "50" "8" ## [[3]] ## [1] "8" "7"  PHP 99 <?php$a = function($s) { foreach(str_split($s)as$c)$b[]=is_numeric($c)?$c:".";return array_filter(explode('.',implode($b))); }; var_dump($a("abc123def456"));
var_dump($a("aitew034snk582:3c")); var_dump($a("as5493tax54\\430-52@g9.fc"));
var_dump(\$a("sasprs]tore\"re\\forz"));


Output

array(2) {
[3]=>
string(3) "123"
[6]=>
string(3) "456"
}
array(3) {
[5]=>
string(3) "034"
[8]=>
string(3) "582"
[9]=>
string(1) "3"
}
array(5) {
[2]=>
string(4) "5493"
[5]=>
string(2) "54"
[6]=>
string(3) "430"
[7]=>
string(2) "52"
[9]=>
string(1) "9"
}
array(0) {
}


JavaScript 88

88 chars when not counting function n(x){}

function n(x){
y=[],i=0,z=t=''
while(z=x[i++])t=!isNaN(z)?t+z:t&&y.push(t)?'':t
if(t)y.push(t)
return y
}