Amazon interview question

find valid strings in a string