Does anyone have any suggestions of how I could implement the following efficiently? I had a go, but started using too many loops and things got messy.

I have an input string that is a group of words without spaces eg "onetwothree". The number of words can vary.

I have a sentence such as "apple banana one two three pear strawberry"

I need a function that would identify and return "one two three" as per the sentence. If the sentence contained "one twothree" or "onetwo three" or even "on e tw o thr ee", that would be returned.

Also, what if multiple instances of the words in the sentence eg "apple onetwo three banana onetwo th r e e pear"???

Any suggestions?