For the fun of it, a production-quality solution in Perl. If you squint really hard, you could even claim that it is functional style:
@x=qw(one two three four five six seven eight nine);
($",%x,$/)=('|',map(($_=>++$x),@x));
print(eval(<>=~s/(?=(@x))|[^\d\n]/$x{$1}/ger=~s/(?=(.)).*(.)/'$1$2'+/gr.0),"\n");