Hello,
Here is one more approach (for a string in A2)
=LOOKUP(LOOKUP(LEN($A2),FIND(ROW($1:$10)-1,$A2)), FIND(" ", " "&TRIM(A2),ROW(OFFSET(A$1,,,LEN($A2)))), MID($A2, ROW(OFFSET(A$1,,,LEN($A2))), MMULT(FIND(" ",{""," "}&TRIM($A2)&" ", ROW(OFFSET(A$1,,,LEN($A2)))),{1;-1})))
Cheers,
Sajan.