# Task

Given a string of English names of digits “collapsed” together, like this:

zeronineoneoneeighttwoseventhreesixfourtwofive


Split the string back into digits:

zero nine one one eight two seven three six four two five


# Rules

• The input is always a string. It always consists of one or more lowercase English digit names, collapsed together, and nothing else.

• The English digit names are zero one two three four five six seven eight nine.
• The output may be a list of strings, or a new string where the digits are delimited by non-alphabetic, non-empty strings. (Your output may also optionally have such strings at the beginning or end, and the delimiters need not be consistent. So even something like {{ zero0onetwo ); is a valid (if absurd) answer for zeroonetwo.)

• The shortest answer in bytes wins.

# Test cases

three -> three
eightsix -> eight six
fivefourseven -> five four seven
ninethreesixthree -> nine three six three
foursixeighttwofive -> four six eight two five
fivethreefivesixthreenineonesevenoneeight -> five three five six three nine one seven one eight
threesevensevensixninenineninefiveeighttwofiveeightsixthreeeight -> three seven seven six nine nine nine five eight two five eight six three eight
zeroonetwothreefourfivesixseveneightnine -> zero one two three four five six seven eight nine

• This is an excellent challenge! The task is extremely easy to understand and verify, but the right approach to use isn't very obvious. And choosing the right approach could make a huge difference in score. +1 :) Nov 20 '17 at 17:27
• After thinking this up, I remembered a similar, but more simplistic challenge on anarchy golf: yesno! It sparked some amazing C answers. I hope to see one of those soon :)
– Lynn
Nov 20 '17 at 17:41
• I do not think my C answer qualifies as such, but hopefully it's a starting point for others with a more twisted sense of humor than myself. Nov 20 '17 at 20:29
• I'm pretty sure I've seen this same challenge, but where you're supposed to print the actual number. I'm almost certain it was also posted by, you, Lynn; but I've lost the link, hook me up with it? Nov 20 '17 at 22:21
• @MichaelDorgan (or any other C coders), you may want to have a look at the algorithm I used in my Befunge answer. A straight conversion of that to C got me a 104 byte solution, which I think beats all of the existing C answers. I'm willing to bet that could be improved upon by someone with more C golfing skills. Nov 21 '17 at 3:06

# GNU sed, 35 bytes

(including +1 for the -r flag)

s/([ots]|[zfn].|(se|th|ei).)../ &/g


Just a simple regexp replacement.

# Ruby, 33 bytes

->s{s.scan(/..[eox]|[tse]?..../)}


Try it online!

(Everybody else is doing it, so why can't we?)

# Perl5, 26 bytes

echo zeronineoneoneeighttwoseventhreesixfourtwofive \
| perl -ple 's/..[eox]|[tse]?..../$& /g'  Or just the program: s/..[eox]|[tse]?..../$& /g


# Deorst, 22 bytes

'..[eox]|[tse]?....'gf


Try it online!

Of course, this uses the regex found by Uriel. Although, it’s great when Deorst beats Pyth and Jelly :P

• Sorry not any more. Nov 25 '17 at 17:05

# Matlab, 432 bytes

A long attempt.

s=char(input('','s'));o=[];while length(s)>0;switch s(1:2);case'ze';o=[o,' ',s(1:4)];s(1:4)=[];case'on';o=[o,' ',s(1:3)];s(1:3)=[];case'tw';o=[o,' ',s(1:3)];s(1:3)=[];case 'th';o=[o,' ',s(1:5)];s(1:5)=[];case'fo';o=[o,' ',s(1:4)];s(1:4)=[];case'fi';o=[o,' ',s(1:4)];s(1:4)=[];case 'si';o=[o,' ',s(1:3)];s(1:3)=[];case'se';o=[o,' ',s(1:5)];s(1:5)=[];case 'ei';o=[o,' ',s(1:5)];s(1:5)=[];otherwise;o=[o,' ',s(1:4)];s(1:4)=[];end;end;o


ungolfed:

s=char(input('','s'))
o=[]
while length(s)>0
switch s(1:2)
case 'ze'
o=[o,' ',s(1:4)]
s(1:4)=[]
case 'on'
o=[o,' ',s(1:3)]
s(1:3)=[]
case 'tw'
o=[o,' ',s(1:3)]
s(1:3)=[]
case 'th'
o=[o,' ',s(1:5)]
s(1:5)=[]
case 'fo'
o=[o,' ',s(1:4)]
s(1:4)=[]
case 'fi'
o=[o,' ',s(1:4)]
s(1:4)=[]
case 'si'
o=[o,' ',s(1:3)]
s(1:3)=[]
case 'se'
o=[o,' ',s(1:5)]
s(1:5)=[]
case 'ei'
o=[o,' ',s(1:5)]
s(1:5)=[]
otherwise
o=[o,' ',s(1:4)]
s(1:4)=[]
end
end
o

• Welcome to PPCG! Nov 26 '17 at 21:08
• Thanks! First golf attempt, so not that great. But, I didn't see any other Matlab! Nov 26 '17 at 21:20

# Ruby, 77 bytes

puts gets.gsub(/(one|two|three|four|five|six|seven|eight|nine)/,' \1 ').strip


Try it online!